@oslojs/crypto
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -105,12 +105,13 @@ import { bigIntBytes } from "@oslojs/binary"; | ||
const kBytes = bigIntBytes(k); | ||
// montgomery ladder | ||
const r = [pointAtInfinity(), new JacobianPoint(point.x, point.y, 1n)]; | ||
for (let i = 0; i < kBytes.byteLength * 8; i++) { | ||
const byte = kBytes[Math.floor(i / 8)]; | ||
const bit = (byte >> (7 - (i % 8))) & 0x01; | ||
const notBit = bit ^ 1; | ||
r[notBit] = this.addJacobian(r[notBit], r[bit]); | ||
r[bit] = this.doubleJacobian(r[bit]); | ||
const bitLength = k.toString(2).length; | ||
let res = pointAtInfinity(); | ||
let temp = new JacobianPoint(point.x, point.y, 1n); | ||
for (let i = 0; i < bitLength; i++) { | ||
const byte = kBytes[kBytes.byteLength - 1 - Math.floor(i / 8)]; | ||
if ((byte >> i % 8) & 0x01) { | ||
res = this.addJacobian(res, temp); | ||
} | ||
temp = this.doubleJacobian(temp); | ||
} | ||
return this.toAffine(r[0]); | ||
return this.toAffine(res); | ||
} | ||
@@ -117,0 +118,0 @@ isOnCurve(point) { |
{ | ||
"name": "@oslojs/crypto", | ||
"type": "module", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "A very basic crypto library", | ||
@@ -86,3 +86,3 @@ "files": [ | ||
"@oslojs/asn1": "0.2.2", | ||
"@oslojs/binary": "0.2.3" | ||
"@oslojs/binary": "0.4.0" | ||
}, | ||
@@ -89,0 +89,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1932
73351
+ Added@oslojs/binary@0.4.0(transitive)
Updated@oslojs/binary@0.4.0