paulmillr / noble-curves

Audited & minimal JS implementation of elliptic curve cryptography.
https://paulmillr.com/noble
MIT License
664 stars 62 forks source link

Implement ElligatorSwift #107

Open paulmillr opened 8 months ago

paulmillr commented 8 months ago

ElligatorSwift: Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes. https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki, https://github.com/bitcoin/bitcoin/blob/master/src/secp256k1/doc/ellswift.md SwiftEC: Shallue-van de Woestijne Indifferentiable Function to Elliptic Curves. https://eprint.iacr.org/2022/759.pdf

Curve25519 & P-521 are incompatible with SwiftEC. Differences from SwiftEC:

TODO: understand if these methods have proper names and types.

encode: (x: bigint | PointType<bigint>) => Uint8Array;
decode: (data: Hex) => Uint8Array;
keygen: () => { privateKey: Uint8Array; publicKey: Uint8Array; };
getSharedSecret: (privateKeyA: Hex, publicKeyB: Hex) => Uint8Array;
getSharedSecretBip324: (privateKeyOurs: Hex, publicKeyTheirs: Hex, publicKeyOurs: Hex, initiating: boolean) => Uint8Array;

Closes gh-8.