Skip to content

Commit 6305e3c

Browse files
Merge pull request #6 from multiparty/dependencies
Force key to be of hex format
2 parents a08c3cf + 604ee77 commit 6305e3c

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@
3838
},
3939
"homepage": "https://github.com/multiparty/oprf#readme",
4040
"dependencies": {
41-
"bn.js": "^4.11.8",
42-
"coveralls": "^3.0.2",
43-
"elliptic": "^6.4.0"
41+
"bn.js": "5.0.0",
42+
"elliptic": "6.5.1"
4443
},
4544
"devDependencies": {
46-
"@types/chai": "^4.1.4",
47-
"@types/mocha": "^5.2.3",
48-
"@types/node": "^10.3.6",
49-
"chai": "^4.1.2",
50-
"libsodium-wrappers-sumo": "^0.7.3",
45+
"@types/chai": "^4.1.7",
46+
"@types/mocha": "^5.2.7",
47+
"@types/node": "^10.14.13",
48+
"chai": "^4.2.0",
49+
"coveralls": "^3.0.4",
50+
"libsodium-wrappers-sumo": "0.7.3",
5151
"mocha": "^5.2.0",
52-
"nyc": "^12.0.2",
53-
"sinon": "^6.3.5",
52+
"nyc": "^14.1.1",
53+
"sinon": "^7.3.2",
5454
"source-map-support": "^0.5.6",
55-
"ts-loader": "^4.4.2",
55+
"ts-loader": "^4.5.0",
5656
"ts-node": "^7.0.0",
57-
"tslint": "^5.10.0",
58-
"typedoc": "^0.13.0",
57+
"tslint": "^5.18.0",
58+
"typedoc": "^0.15.0",
5959
"types-bn": "0.0.1",
6060
"typescript": "^2.9.2",
61-
"webpack": "^4.14.0",
62-
"webpack-cli": "^3.0.8"
61+
"webpack": "^4.40.2",
62+
"webpack-cli": "^3.3.9"
6363
},
6464
"peerDependencies": {
65-
"libsodium-wrappers-sumo": "^0.7.3"
65+
"libsodium-wrappers-sumo": "0.7.3"
6666
}
6767
}

src/oprf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class OPRF {
9898
/**
9999
* Salts a point using a key as a scalar
100100
* @param point number array representation of a masked point
101-
* @param key private key of server
101+
* @param key private key of server in hex format
102102
* @returns {string} salted point in hex format
103103
*/
104104
public scalarMult(point: number[], key: string): number[] {
@@ -107,7 +107,7 @@ export class OPRF {
107107
throw new Error('Input is not a valid ED25519 point.');
108108
}
109109

110-
const scalar: BN = new BN(key);
110+
const scalar: BN = new BN(key, 16);
111111
// point: elliptic point
112112
const p = this.ed.decodePoint(point);
113113

test/oprf.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('End-to-End', () => {
136136
const hashedPoint = oprf.hashToPoint(input);
137137
const result = oprf.scalarMult(hashedPoint, scalarKey);
138138

139-
const known_result = [104, 232, 164, 133, 219, 182, 80, 68, 105, 227, 199, 179, 193, 54, 190, 2, 98, 151, 102, 236, 117, 228, 252, 88, 186, 89, 224, 226, 27, 186, 238, 126];
139+
const known_result = [67, 211, 62, 241, 3, 58, 144, 120, 39, 14, 255, 148, 90, 209, 115, 56, 238, 5, 58, 143, 33, 206, 223, 209, 240, 173, 177, 214, 71, 88, 131, 222];
140140
expect(unmasked).to.deep.equals(result).to.deep.equals(known_result);
141141
});
142142

@@ -236,7 +236,7 @@ describe('Expected Behavior', () => {
236236
const unmasked2 = oprf.unmaskInput(salted2, masked2.mask);
237237
const unmasked3 = oprf.unmaskInput(salted3, masked3.mask);
238238

239-
const known_output = [44, 245, 118, 84, 55, 249, 213, 84, 216, 193, 217, 165, 140, 215, 79, 3, 249, 81, 22, 79, 170, 98, 92, 55, 88, 56, 55, 186, 101, 169, 232, 31];
239+
const known_output = [221, 1, 0, 60, 186, 172, 201, 218, 147, 12, 254, 230, 80, 113, 61, 205, 21, 27, 0, 213, 57, 192, 34, 56, 82, 185, 185, 153, 8, 250, 191, 19];
240240

241241
expect(unmasked1).to.deep.equals(unmasked2).to.deep.equals(unmasked3).to.deep.equals(known_output);
242242
});

0 commit comments

Comments
 (0)