Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sign&verify and external witnesses #57

Merged
merged 8 commits into from Oct 22, 2019

Conversation

SebastienGllmt
Copy link
Contributor

@SebastienGllmt SebastienGllmt commented Oct 20, 2019

I add a sign function to PrivateKey and verify to PublicKey (this requires input-output-hk/chain-libs#118)

I designed this so we can easily add more signature key in the future if needed.

Usage

// signing test

const buff1 = Buffer.from('hello', 'utf-8');
const signature = key.sign(buff1);

// ed25519_sig1eu603zrj68h55dg9pwvmvc4wc48zy7l8m83m0fgdxekn7mx8jmvhyd3anncufde39l4vv2drpx409t2g0r7nc9m303qu06nasj3kkqqvv2xhz
console.log(signature.to_bech32());

// cf34f88872d1ef4a35050b99b662aec54e227be7d9e3b7a50d366d3f6cc796d972363d9cf1c4b7312feac629a309aaf2ad4878fd3c17717c41c7ea7d84a36b00
console.log(Buffer.from(signature.to_bytes()).toString('hex'));

// cf34f88872d1ef4a35050b99b662aec54e227be7d9e3b7a50d366d3f6cc796d972363d9cf1c4b7312feac629a309aaf2ad4878fd3c17717c41c7ea7d84a36b00
console.log(signature.to_hex());

// verify test

const pubKey = key.to_public();
const success = pubKey.verify(buff1, signature); // true as expected

const buff2 = Buffer.from('world', 'utf-8');
const failed = pubKey.verify(buff2, signature); // failed as expected

Other change

I also added AccountWitness and UtxoWitness so that the WASM bindings can easily support hardware wallets in the future

@SebastienGllmt SebastienGllmt changed the title Add sign for PrivateKey Add sign&verify and external witnesses Oct 21, 2019
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@NicolasDP NicolasDP merged commit dde3a70 into input-output-hk:master Oct 22, 2019
@SebastienGllmt SebastienGllmt deleted the sign-and-verify branch October 22, 2019 21:23
SebastienGllmt pushed a commit to SebastienGllmt/js-chain-libs that referenced this pull request May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants