docknetwork / crypto-wasm-ts Goto Github PK
View Code? Open in Web Editor NEWTypescript abstractions over Rust crypto library's WASM wrapper
License: Apache License 2.0
Typescript abstractions over Rust crypto library's WASM wrapper
License: Apache License 2.0
Hi!
I will be using dock libraries and dock wallet for https://github.com/privency
The voting system relies heavily on hash of credential attributes - aka pseudonyms.
Pseudonyms have been implemented in Pseudonym.js
, and thoroughly tested in pseudonym.spec.ts
, but they are not available in Presentations.
I worked on adding support for pseudonyms in presentation, allowing:
I am sending a draft PR, and would love your feedback.
After work is finished here, I'm happy to help bringing support for it in the wallet.
crypto-wasm-ts/src/accumulator/accumulator.ts
Line 880 in 0d0360b
Here's a rough reproducer
async function perfTest<T>(name: string, rounds: number, f: (i: number) => Promise<T>): Promise<T[]> {
const result: T[] = []
const startTime = Date.now()
for (let i = 0; i < rounds; i++) {
result.push(await f(i))
}
const endTime = Date.now()
console.log(`Performance test for ${name}: Ran ${rounds} rounds in ${endTime - startTime} ms\nAverage time: ${(endTime - startTime) / rounds} ms`)
return result
}
const params = UniversalAccumulator.generateParams()
const keypair = UniversalAccumulator.generateKeypair(params)
const state = new InMemoryUniversalState()
const init = new InMemoryInitialElementsStore()
const test_data_count = 20
const test_non_data_count = 10
const accum = await UniversalAccumulator.initialize(0, params, keypair.secretKey, init)
// Append random data
const testData = [...Array(test_data_count)].map(() => crypto.randomBytes(32))
await perfTest('append single', test_data_count, async (i) => {
const data = UniversalAccumulator.encodeBytesAsAccumulatorMember(testData[i])
await accum.add(data, keypair.sk, state)
return data
})
// Generate non-membership proofs
const nonData = [...Array(test_non_data_count)].map(() => UniversalAccumulator.encodeBytesAsAccumulatorMember(crypto.randomBytes(32)))
const witness = await perfTest('non-member single prove', nonData.length, async (i) => {
const witness = await accum.nonMembershipWitness(nonData[i], state, keypair.sk, params, init)
return witness
})
const validator = UniversalAccumulator.fromAccumulated(accum.accumulated)
await perfTest('non-member single validate', nonData.length, async (i) => {
const valid = validator.verifyNonMembershipWitness(nonData[i], witness[i], keypair.pk, params)
expect(valid).toEqual(true)
})
// Batch non-membership proofs
const batch = [...Array(test_non_data_count)].map(() => UniversalAccumulator.encodeBytesAsAccumulatorMember(crypto.randomBytes(32)))
const [batchWitness] = await perfTest('non-member batch prove', 1, async () => {
const witness = await accum.nonMembershipWitnessesForBatch(batch, state, keypair.sk, params, init)
return witness
})
void batchWitness
// await perfTest('non-member batch verify', batchWitness.length, async (i) => {
// const valid = validator.verifyNonMembershipWitness(batch[i], batchWitness[i], keypair.pk, params)
// expect(valid).toEqual(true)
// })
I'm trying to use the module in a browser, but it cannot be resolved correctly: Uncaught TypeError: Failed to resolve module specifier "@docknetwork/crypto-wasm-ts".
Any suggestions?
I was reading this test but I could not see where the "blood" comes in this test?
https://github.com/docknetwork/crypto-wasm-ts/blob/master/tests/composite-proofs/msg-js-obj/r1cs/mimc-hash.spec.ts
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.