starkbank_ecdsa v0.0.1 EllipticCurve.Ecdsa View Source
Used to sign and verify signatures using the Elliptic Curve Digital Signature Algorithm (ECDSA)
Functions:
- sign()
- verify?()
Link to this section Summary
Functions
Generates a message signature based on a private key
Verifies a message signature based on a public key
Link to this section Functions
Generates a message signature based on a private key
Parameters:
- message [string]: message that will be signed
- privateKey [%EllipticCurve.PrivateKey.Data]: private key data associated with the signer
options [keyword list]: refines request
- hashfunc [:method]: defines the hash function applied to the message. Must be compatible with :crypto.hash. Default: :sha256;
Returns signature:
- signature [string]: base-64 message signature;
Example:
iex> EllipticCurve.Ecdsa.sign("my message", privateKey)
"MEQCIFp2TrQ6RlThbEOeYin2t+Dz3TAebeK/kinZaU0Iltm4AiBXyvyCTwgjOBo5eZNssw/3shTqn8eHZyoRiToSttrRFw=="
Verifies a message signature based on a public key
Parameters:
- message [string]: message that will be signed
- signature [%EllipticCurve.Signature.Data]: signature associated with the message
- publicKey [%EllipticCurve.PublicKey.Data]: public key associated with the message signer
options [keyword list]: refines request
- hashfunc [:method]: defines the hash function applied to the message. Must be compatible with :crypto.hash. Default: :sha256;
Returns:
- verified [bool]: true if message, public key and signature are compatible, false otherwise;
Example:
iex> EllipticCurve.Ecdsa.verify?(message, signature, publicKey)
true
iex> EllipticCurve.Ecdsa.verify?(wrongMessage, signature, publicKey)
false
iex> EllipticCurve.Ecdsa.verify?(message, wrongSignature, publicKey)
false
iex> EllipticCurve.Ecdsa.verify?(message, signature, wrongPublicKey)
false