@stellot/crypto
Version:
Crypto libraries for front and backend
29 lines (28 loc) • 809 B
JavaScript
import { BigInteger as BigInt } from 'jsbn';
export default class EncryptedValue {
constructor(a, b) {
switch (typeof a) {
case 'string':
this.a = new BigInt(a, 16);
break;
case 'number':
this.a = new BigInt(`${a}`);
break;
default:
this.a = a;
}
switch (typeof b) {
case 'string':
this.b = new BigInt(b, 16);
break;
case 'number':
this.b = new BigInt(`${b}`);
break;
default:
this.b = b;
}
}
multiply(encryptedValue) {
return new EncryptedValue(this.a.multiply(encryptedValue.a), this.b.multiply(encryptedValue.b));
}
}