Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client security, Core #64

Merged
merged 68 commits into from
Aug 6, 2021
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6b1b353
aes and argon2
polymorpher Aug 2, 2021
8d32fe8
batch hash functions; genOTP - do not compute report interval inside
polymorpher Aug 2, 2021
3a68c25
double otp and controlled randomness support; argon2 support; functio…
polymorpher Aug 2, 2021
78ff562
store randomnessResults and return in merkle tree computation
polymorpher Aug 2, 2021
993b66b
fix bug with sha256b
polymorpher Aug 2, 2021
c68b9db
fix deprecated method in wallet test
polymorpher Aug 2, 2021
e4225ef
expand test util for createWallet
polymorpher Aug 2, 2021
f77b7b7
make computeMerkleTree and recoverRandomness async
polymorpher Aug 2, 2021
ec451dd
sha256b async
polymorpher Aug 2, 2021
dac8df1
make worker onmessagelisteners async
polymorpher Aug 2, 2021
12dd2b7
return counter on test util createwallet
polymorpher Aug 2, 2021
7119e60
client security test
polymorpher Aug 2, 2021
658f052
Add use two otp options on create wallet
haolinj Aug 3, 2021
0d7ce6b
Use same name for second otp with suffix and adjust the instruction text
haolinj Aug 4, 2021
0f497a4
Preset second otp qr data and not overriding otp name in the state
haolinj Aug 4, 2021
bef6494
Merge branch 'master' of github.com:polymorpher/one-wallet into clien…
haolinj Aug 4, 2021
7a845ae
Add otp2 for transfer and potentially restore wallet
haolinj Aug 4, 2021
0deeefc
Merge branch 'master' into client-security
polymorpher Aug 4, 2021
a9adb9d
Merge branch 'client-security' of github.com:polymorpher/one-wallet i…
haolinj Aug 4, 2021
e1bff30
Auto focus otp2 input box when otp1 input box is filled
haolinj Aug 4, 2021
f606270
fix issues with wasm in webpack compilation
polymorpher Aug 5, 2021
73deab0
improve Create screen texts, positioning, and user experience
polymorpher Aug 5, 2021
a5b9f93
remove redundant new lines
polymorpher Aug 5, 2021
3294346
decodeOtp util
polymorpher Aug 5, 2021
7b0748d
fix bug with hseed setter
polymorpher Aug 5, 2021
9d166f8
fix progress observer
polymorpher Aug 5, 2021
eff7ca2
computeEOTP with async, hasher, double OTP, and randomness
polymorpher Aug 5, 2021
01081a3
transfer test with double otp, randomness, argon2 and sha256
polymorpher Aug 5, 2021
97a36a0
await eotp in all tests; make all tests pass
polymorpher Aug 5, 2021
eb497c9
await EOTP everywhere
polymorpher Aug 5, 2021
d3253c2
more parameters in eotpbuilder.fromOtp
polymorpher Aug 5, 2021
41c3f4a
Merge branch 'client-security' into client-security-frontend
polymorpher Aug 5, 2021
b549b6e
sync flow.js from frontend branch
polymorpher Aug 5, 2021
106cbef
rand, hasher, nonce, otp2 in commitReveal flow
polymorpher Aug 5, 2021
76d6e48
allow arbitrary paramsHash in recover; use last leaf as recover EOTP
polymorpher Aug 5, 2021
54a78a8
compile contracts
polymorpher Aug 5, 2021
c2eaa4c
new computeRecoveryHash; deprecate bruteforceEOTP
polymorpher Aug 5, 2021
a7e5845
special treatment for recover operation in _verifyReveal and _complet…
polymorpher Aug 5, 2021
7b57e9f
compiled contracts
polymorpher Aug 5, 2021
dcce7a2
fix bug with computeRecoveryHash
polymorpher Aug 5, 2021
8fc1c24
new recovery flow
polymorpher Aug 5, 2021
dfcc39b
new recovery test; all tests passing
polymorpher Aug 5, 2021
266c747
Merge remote-tracking branch 'origin/client-security' into client-sec…
polymorpher Aug 5, 2021
57ef96b
minor
polymorpher Aug 5, 2021
f4346b8
clean up
polymorpher Aug 5, 2021
ace8dd7
ditto
polymorpher Aug 5, 2021
ca1f770
ONE Wallet -> 1wallet
polymorpher Aug 5, 2021
dc64057
otp entry name change
polymorpher Aug 5, 2021
b6ebe9b
text update
polymorpher Aug 5, 2021
26a0b54
better syntax for computeRecoveryHash
polymorpher Aug 5, 2021
e213814
v8 contract
polymorpher Aug 5, 2021
ec5ab14
revealRecovery with data
polymorpher Aug 5, 2021
36a3594
doRecovery
polymorpher Aug 5, 2021
8c3478e
skip checking minor version
polymorpher Aug 5, 2021
4d658c5
flow: allow index override
polymorpher Aug 5, 2021
344f9bd
relayer: show reveal params on verbose mode
polymorpher Aug 5, 2021
5970e3e
doRecovery: fix issues
polymorpher Aug 5, 2021
7c13508
rearrange ui elements
polymorpher Aug 5, 2021
45af94f
make restore work
polymorpher Aug 5, 2021
08834d7
Add 2 otp for recover address setup
haolinj Aug 5, 2021
e11ec8d
Merge branch 'client-security-frontend' of github.com:polymorpher/one…
haolinj Aug 5, 2021
6cb198c
Merge pull request #65 from polymorpher/client-security-frontend
polymorpher Aug 5, 2021
f55ab96
Merge branch 'master' into client-security
polymorpher Aug 5, 2021
608426b
add randomness by default
polymorpher Aug 5, 2021
7d32482
better test progress bar and fix a null issue
polymorpher Aug 6, 2021
c6ec27b
versioned security parameters; use that everywhere applicable
polymorpher Aug 6, 2021
cdbec6e
move recoverRandomness to worker
polymorpher Aug 6, 2021
4d4b1b5
Merge pull request #66 from polymorpher/client-security-randomness
polymorpher Aug 6, 2021
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
Prev Previous commit
Next Next commit
computeEOTP with async, hasher, double OTP, and randomness
polymorpher committed Aug 5, 2021
commit eff7ca2bb4175f151cd756507483ca1941c4974a
37 changes: 26 additions & 11 deletions code/lib/onewallet.js
Original file line number Diff line number Diff line change
@@ -24,9 +24,9 @@ const computeMerkleTree = async ({
const seed = processOtpSeed(otpSeed)
const seed2 = otpSeed2 && processOtpSeed(otpSeed2)
// console.log('Generating Wallet with parameters', { seed, height, otpInterval, effectiveTime })
const buildProgressObserver = (max, j) => (i, n) => (i + (j || 0)) % reportInterval === 0 && progressObserver(i + (j || 0), max || n, 0)
const otps = genOTP({ seed, counter, n, progressObserver: buildProgressObserver(seed2 ? n * 2 : n) })
const otps2 = seed2 && genOTP({ seed: seed2, counter, n, progressObserver: buildProgressObserver(n * 2, n) })
const buildProgressObserver = (max, stage, offset) => (i, n) => (i + (offset || 0)) % reportInterval === 0 && progressObserver(i + (offset || 0), max || n, stage || 0)
const otps = genOTP({ seed, counter, n, progressObserver: buildProgressObserver(seed2 ? n * 2 : n, 0, 0) })
const otps2 = seed2 && genOTP({ seed: seed2, counter, n, progressObserver: buildProgressObserver(n * 2, 0, n) })
// legacy mode: no randomness, no seed2: 26 bytes for seed hash, 2 bytes for nonce, 4 bytes for OTP
// single otp mode: 22 bytes for seed hash, 2 bytes for nonce, 4 bytes for OTP, 4 bytes for randomness
// double otp mode: 18 bytes for seed hash, 2 bytes for nonce, 4 bytes for OTP, 4 bytes for second OTP, 4 bytes for randomness
@@ -70,8 +70,8 @@ const computeMerkleTree = async ({
}
}
// TODO: parallelize this
const eotps = await hasher(input, { progressObserver: buildProgressObserver() })
const leaves = await sha256b(eotps, { progressObserver: buildProgressObserver() })
const eotps = await hasher(input, { progressObserver: buildProgressObserver(n * maxOperationsPerInterval * 2, 1) })
const leaves = await sha256b(eotps, { progressObserver: buildProgressObserver(n * maxOperationsPerInterval * 2, 1, n * maxOperationsPerInterval) })
const layers = []
layers.push(leaves)
for (let j = 1; j < height; j += 1) {
@@ -155,16 +155,31 @@ const computeSetRecoveryAddressHash = ({ address }) => {
return { hash: keccak(input), bytes: input }
}

// otp, uint8array, 4
// otp, uint8array[4]
// otp2, uint8array[4], optional
// rand, integer, optional
// hseed, uint8array, 26, sha256 hash of the otp seed
// nonce, positive integer (within 15-bit)
const computeEOTP = ({ otp, hseed, nonce = 0 }) => {
const computeEOTP = async ({ otp, otp2, rand = null, hseed, nonce = 0, hasher = sha256b }) => {
const buffer = new Uint8Array(32)
const nb = new Uint16Array([nonce])
buffer.set(hseed.slice(0, 26))
buffer.set(nb, 26)
buffer.set(otp, 28)
return fastSHA256(buffer)
buffer.set(hseed)
buffer.set(nb, hseed.length)
buffer.set(otp, hseed.length + 2)
if (otp2) {
buffer.set(otp2, hseed.length + 6)
}
console.log('otp', otp, hexView(otp))
console.log('otp2', otp2, hexView(otp2))
console.log('buffer', buffer, hexView(buffer))
if (rand !== null) {
const rb = new Uint8Array(4)
const rv = new DataView(rb.buffer)
rv.setUint32(0, rand, false)
console.log('rb', rb)
buffer.set(rb, 28)
}
return hasher(buffer)
}

const computeRecoveryHash = () => {