[she] add SecretKey.isZero(c)

dev
MITSUNARI Shigeo 7 years ago
parent 2f53f90067
commit df1921c3c1
  1. 23
      docs/demo/she.js

@ -225,6 +225,16 @@
mod.Runtime.stackRestore(stack)
return r
}
const callIsZero = function(func, sec, c) {
let stack = mod.Runtime.stackSave()
let secPos = mod.Runtime.stackAlloc(sec.length * 4)
let cPos = mod.Runtime.stackAlloc(c.length * 4)
copyFromUint32Array(secPos, sec);
copyFromUint32Array(cPos, c);
let r = func(secPos, cPos)
mod.Runtime.stackRestore(stack)
return r
}
// reRand(c)
const callReRand = function(func, c, pub) {
let stack = mod.Runtime.stackSave()
@ -322,6 +332,19 @@
}
return callDec(dec, this.a_, c.a_)
}
isZero(c) {
let isZero = null
if (exports.CipherTextG1.prototype.isPrototypeOf(c)) {
isZero = mod._sheIsZeroG1
} else if (exports.CipherTextG2.prototype.isPrototypeOf(c)) {
isZero = mod._sheIsZeroG2
} else if (exports.CipherTextGT.prototype.isPrototypeOf(c)) {
isZero = mod._sheIsZeroGT
} else {
throw('exports.SecretKey.isZero:not supported')
}
return callIsZero(isZero, this.a_, c.a_)
}
}
exports.getSecretKeyFromHexStr = function(s) {

Loading…
Cancel
Save