mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.0 KiB
1.0 KiB
Signer
Elliptic curve cryptography is used in most blockchain projects to sign transactions. Using Node.js base library we will practise simple signatures.
Instructions
-
Create a function
init()
that generates a cryptographic key pair on any elliptic curve and returns the public key in any format. -
Create a function
signer(message)
that takes as arguments a message and returns the signature of the message (using thesha256
algorithm and the keys generated with init). -
create a function
verifier(message, pubKey, signature)
that takes as arguments a message, a public key and a signature and returns a boolean if the signature is valid.
Usage
const message = 'This is a message to sign'
const pubKey = init()
const signature = signer(message)
console.log(verifier(message, pubKey, signature))
// expected result :
// true