34 lines
1021 B
TypeScript
34 lines
1021 B
TypeScript
![]() |
import chai from 'chai'
|
||
|
|
||
|
import { solidity } from 'ethereum-waffle'
|
||
|
import { BigNumber } from 'ethers'
|
||
|
import { Primitives } from 'lib/crypto'
|
||
|
|
||
|
chai.use(solidity)
|
||
|
|
||
|
const expect = chai.expect
|
||
|
|
||
|
describe('crypto', () => {
|
||
|
describe('namespace Crypto', () => {
|
||
|
describe('namespace Primitives', () => {
|
||
|
it('createDeposit', () => {
|
||
|
const deposit = Primitives.createDeposit()
|
||
|
// @ts-ignore
|
||
|
const limit = BigNumber.from(2).pow(248).sub(1)
|
||
|
|
||
|
expect(deposit.nullifier).to.exist
|
||
|
expect(deposit.secret).to.exist
|
||
|
expect(deposit.preimage).to.exist
|
||
|
expect(deposit.commitment).to.exist
|
||
|
expect(deposit.commitmentHex).to.exist
|
||
|
expect(deposit.nullifierHash).to.exist
|
||
|
|
||
|
// From the whitepaper, the nullifier k E B^248
|
||
|
expect(BigNumber.from(deposit.nullifier.toString())).to.be.lte(limit)
|
||
|
// From the whitepaper, the randomness r E B^248
|
||
|
expect(BigNumber.from(deposit.secret.toString())).to.be.lte(limit)
|
||
|
})
|
||
|
})
|
||
|
})
|
||
|
})
|