-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add one more unittest and address more comments
- Loading branch information
James Zheng
committed
Jul 2, 2022
1 parent
f8cf50c
commit 900431a
Showing
5 changed files
with
68 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
client-sdk/ts-web/rt/src/mrae.ts → client-sdk/ts-web/rt/src/mrae/deoxysii.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import * as oasisRT from './../src'; | ||
import * as ed from '@noble/ed25519'; | ||
import * as oasis from '@oasisprotocol/client'; | ||
import * as nacl from 'tweetnacl'; | ||
|
||
describe('mrae', () => { | ||
describe('symmetricKey', () => { | ||
it('Should drive symmetric key correctly', async () => { | ||
const privateKeyHex = "c07b151fbc1e7a11dff926111188f8d872f62eba0396da97c0a24adb75161750"; | ||
it('Should drive symmetric key correctly', () => { | ||
const privateKeyHex = "c07b151fbc1e7a11dff926111188f8d872f62eba0396da97c0a24adb75161750"; | ||
const privateKey = oasis.misc.fromHex(privateKeyHex); | ||
const publicKey = ed.curve25519.scalarMultBase(privateKey); | ||
const publicKey = nacl.scalarMult.base(privateKey); | ||
expect(oasis.misc.toHex(publicKey)).toEqual("3046db3fa70ce605457dc47c48837ebd8bd0a26abfde5994d033e1ced68e2576"); | ||
const sharedKey = oasisRT.mrae.deriveSymmetricKey(publicKey, privateKey); | ||
expect(oasis.misc.toHex(sharedKey)).toEqual("e69ac21066a8c2284e8fdc690e579af4513547b9b31dd144792c1904b45cf586"); | ||
const sharedKey = oasisRT.mraeDeoxysii.deriveSymmetricKey(publicKey, privateKey); | ||
expect(oasis.misc.toHex(sharedKey)).toEqual("e69ac21066a8c2284e8fdc690e579af4513547b9b31dd144792c1904b45cf586"); | ||
}); | ||
}); | ||
}); |