Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinejohn/blind-signatures
Chaum's Blind Signatures
https://github.com/kevinejohn/blind-signatures
blind blind-signatures chaum ecash javascript signature
Last synced: about 1 month ago
JSON representation
Chaum's Blind Signatures
- Host: GitHub
- URL: https://github.com/kevinejohn/blind-signatures
- Owner: kevinejohn
- License: mit
- Created: 2018-01-21T00:52:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:32:07.000Z (almost 2 years ago)
- Last Synced: 2024-04-27T12:02:42.061Z (8 months ago)
- Topics: blind, blind-signatures, chaum, ecash, javascript, signature
- Language: JavaScript
- Size: 203 KB
- Stars: 35
- Watchers: 3
- Forks: 13
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Chaum's Blind Signature
[![NPM Package](https://img.shields.io/npm/v/blind-signatures.svg?style=flat-square)](https://www.npmjs.org/package/blind-signatures)
### Two implementations of RSA Blind Signatures
1. `./rsablind.js`
https://en.wikipedia.org/wiki/Blind_signature2. `./rsablind2.js`
https://github.com/arisath/Blind-RSAThe RSA key generation uses the node-only module `node-rsa` but everything else *should* work outside of node.js
## Use
`npm install --save blind-signatures`
```
const BlindSignature = require('blind-signatures');const Bob = {
key: BlindSignature.keyGeneration({ b: 2048 }), // b: key-length
blinded: null,
unblinded: null,
message: null,
};const Alice = {
message: 'Hello Chaum!',
N: null,
E: null,
r: null,
signed: null,
unblinded: null,
};// Alice wants Bob to sign a message without revealing it's contents.
// Bob can later verify he did sign the messageconsole.log('Message:', Alice.message);
// Alice gets N and E variables from Bob's key
Alice.N = Bob.key.keyPair.n.toString();
Alice.E = Bob.key.keyPair.e.toString();const { blinded, r } = BlindSignature.blind({
message: Alice.message,
N: Alice.N,
E: Alice.E,
}); // Alice blinds message
Alice.r = r;// Alice sends blinded to Bob
Bob.blinded = blinded;const signed = BlindSignature.sign({
blinded: Bob.blinded,
key: Bob.key,
}); // Bob signs blinded message// Bob sends signed to Alice
Alice.signed = signed;const unblinded = BlindSignature.unblind({
signed: Alice.signed,
N: Alice.N,
r: Alice.r,
}); // Alice unblinds
Alice.unblinded = unblinded;// Alice verifies
const result = BlindSignature.verify({
unblinded: Alice.unblinded,
N: Alice.N,
E: Alice.E,
message: Alice.message,
});
if (result) {
console.log('Alice: Signatures verify!');
} else {
console.log('Alice: Invalid signature');
}// Alice sends Bob unblinded signature and original message
Bob.unblinded = Alice.unblinded;
Bob.message = Alice.message;// Bob verifies
const result2 = BlindSignature.verify2({
unblinded: Bob.unblinded,
key: Bob.key,
message: Bob.message,
});
if (result2) {
console.log('Bob: Signatures verify!');
} else {
console.log('Bob: Invalid signature');
}
```