Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Identity recovery
Commits
ae4cea62
Commit
ae4cea62
authored
3 years ago
by
Bijun Li
Browse files
Options
Download
Email Patches
Plain Diff
Update vss lib for share hash
parent
c6da190a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/vss/lib/index.js
+16
-0
packages/vss/lib/index.js
packages/vss/test/vss.js
+4
-1
packages/vss/test/vss.js
with
20 additions
and
1 deletion
+20
-1
packages/vss/lib/index.js
+
16
-
0
View file @
ae4cea62
...
...
@@ -158,6 +158,22 @@ exports.verifyShare = function (bls, share, vvec) {
return
Boolean
(
isEqual
)
}
/**
* calculates a hash against a share
* @param {Object} bls - an instance of [bls-wasm](https://github.com/herumi/bls-wasm)
* @param {Object} share - a share to be verified
* @return {String}
*/
exports
.
hashShare
=
function
(
bls
,
share
)
{
const
sk
=
new
bls
.
SecretKey
()
sk
.
deserialize
(
share
.
sk
)
const
sHash
=
new
bls
.
Fr
()
sHash
.
setHashOf
(
sk
.
serializeToHexStr
())
return
sHash
.
serializeToHexStr
()
}
/**
* recovers the secret from a selection of shares
* @param {Object} bls - an instance of [bls-wasm](https://github.com/herumi/bls-wasm)
...
...
This diff is collapsed.
Click to expand it.
packages/vss/test/vss.js
+
4
-
1
View file @
ae4cea62
...
...
@@ -18,6 +18,9 @@ const curveTest = (curveType, name) => {
setup
.
shares
.
forEach
(
share
=>
{
const
verified
=
vss
.
verifyShare
(
bls
,
share
,
result
.
verificationVector
)
assert
.
strict
.
deepEqual
(
verified
,
true
,
'
should verify share
'
)
const
shareHash
=
vss
.
hashShare
(
bls
,
share
)
console
.
log
(
'
shareHash:
'
,
shareHash
)
})
var
reSecret
=
vss
.
recoverSecret
(
bls
,
setup
.
shares
.
slice
(
0
,
threshold
))
...
...
@@ -36,7 +39,7 @@ const curveTest = (curveType, name) => {
reSecret
=
vss
.
recoverSecret
(
bls
,
renewal
.
shares
.
slice
(
0
,
threshold
))
const
sec2
=
new
bls
.
SecretKey
()
sec2
.
deserialize
(
reSecret
)
console
.
log
(
'
recovered:
'
,
sec2
.
serializeToHexStr
())
console
.
log
(
'
renew-
recovered:
'
,
sec2
.
serializeToHexStr
())
assert
.
strict
.
deepEqual
(
reSecret
,
result
.
secret
,
'
secret should not change after share renewal
'
)
}
catch
(
e
)
{
console
.
log
(
`TEST FAIL
${
e
}
`
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets