From df1921c3c182805bad9ea0c375677c343c9b7a4d Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 23 Nov 2017 07:00:06 +0900 Subject: [PATCH] [she] add SecretKey.isZero(c) --- docs/demo/she.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/demo/she.js b/docs/demo/she.js index 6668494..834a876 100644 --- a/docs/demo/she.js +++ b/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) {