Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"description": "Browser-compatible client for Secure Polling System.",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "mocha"
},
"author": "Karissa McKelvey <[email protected]>",
"license": "GPL",
"dependencies": {
"bn.js": "^4.11.8"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^5.1.1"
}
}
16 changes: 16 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const assert = require('chai').assert,
{User, blindKey} = require('./user');

describe('User', function() {
beforeEach(function() {
this.user = new User();
});

it("generates keys", function() {
this.user.generateKeypair();
});

it('blindKey', function() {
});
})

54 changes: 54 additions & 0 deletions user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { createECDH } = require('crypto'),
secp256k1 = 'secp256k1';

class User {
// I think ECDH and ECDSA keys are generally interchangable.
generateKeypair() {
this.ecdh = createECDH('secp256k1');
this.keys = this.ecdh.generateKeys();
}
sendBlindedKey() {
// copy the go implementation here:
// https://github.com/securepollingsystem/registrar/blob/c2a8102fc07cdc4f0ea3ae442707d50b3de6fb8f/voter/voter.go#L37
//
// the bulk of this will be copying the blinding stuff from here:
// https://github.com/securepollingsystem/registrar/blob/c2a8102fc07cdc4f0ea3ae442707d50b3de6fb8f/blind/requester.go#L25
}
getSignature() {
}
}

function blindKey(pubKey) {
}

function newRequest(Q, R, m) {
// https://github.com/securepollingsystem/registrar/blob/c2a8102fc07cdc4f0ea3ae442707d50b3de6fb8f/blind/requester.go#L25
let a, b, bInv, c;
}

function randFieldElement() {
// https://github.com/securepollingsystem/registrar/blob/c2a8102fc07cdc4f0ea3ae442707d50b3de6fb8f/blind/random.go#L13
}

const BN = require('bn.js');

// https://github.com/securepollingsystem/registrar/blob/c2a8102fc07cdc4f0ea3ae442707d50b3de6fb8f/blind/secp256k1.go#L33
const Secp256kParams = {
p: new BN('FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F', 16),
a: new BN('00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000', 16),
b: new BN('00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000007', 16),
// this is the compressed form of G... What does that mean?
G: new BN('02 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798', 16),
n: new BN('FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141', 16),
h: new BN('01', 16),
/*
P: curve.P,
N: curve.N,
B: curve.B,
Gx: curve.Gx,
Gy: curve.Gy,
BitSize: curve.BitSize,
*/
}

Object.assign(module.exports, {User, blindKey});