verkle-cryptography-wasm
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,3 +0,3 @@ | ||
export { Point } from './point'; | ||
export { commitToPoly, batchMapToScalarField } from './point'; | ||
export { Point } from './point.js'; | ||
export { commitToPoly, batchMapToScalarField } from './point.js'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.batchMapToScalarField = exports.commitToPoly = exports.Point = void 0; | ||
var point_1 = require("./point"); | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return point_1.Point; } }); | ||
var point_2 = require("./point"); | ||
Object.defineProperty(exports, "commitToPoly", { enumerable: true, get: function () { return point_2.commitToPoly; } }); | ||
Object.defineProperty(exports, "batchMapToScalarField", { enumerable: true, get: function () { return point_2.batchMapToScalarField; } }); | ||
var point_js_1 = require("./point.js"); | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return point_js_1.Point; } }); | ||
var point_js_2 = require("./point.js"); | ||
Object.defineProperty(exports, "commitToPoly", { enumerable: true, get: function () { return point_js_2.commitToPoly; } }); | ||
Object.defineProperty(exports, "batchMapToScalarField", { enumerable: true, get: function () { return point_js_2.batchMapToScalarField; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { ElementWrapper as PointWrapper } from '../wasm/rust_verkle_wasm'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings'; | ||
import { ElementWrapper as PointWrapper } from '../wasm/rust_verkle_wasm.js'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings/index.js'; | ||
export declare class Point { | ||
@@ -4,0 +4,0 @@ inner: PointWrapper; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.batchMapToScalarField = exports.commitToPoly = exports.Point = void 0; | ||
const rust_verkle_wasm_1 = require("../wasm/rust_verkle_wasm"); | ||
const ellipticCurveCryptographyBindings_1 = require("../ellipticCurveCryptographyBindings"); | ||
const rust_verkle_wasm_js_1 = require("../wasm/rust_verkle_wasm.js"); | ||
const index_js_1 = require("../ellipticCurveCryptographyBindings/index.js"); | ||
class Point { | ||
@@ -11,3 +11,3 @@ constructor(inner) { | ||
static fromBytes(bytes) { | ||
return new Point(rust_verkle_wasm_1.ElementWrapper.fromBytes(bytes)); | ||
return new Point(rust_verkle_wasm_js_1.ElementWrapper.fromBytes(bytes)); | ||
} | ||
@@ -18,6 +18,6 @@ static fromPointWrapper(inner) { | ||
add(other) { | ||
return new Point((0, rust_verkle_wasm_1.element_add)(this.inner, other.inner)); | ||
return new Point((0, rust_verkle_wasm_js_1.element_add)(this.inner, other.inner)); | ||
} | ||
sub(other) { | ||
return new Point((0, rust_verkle_wasm_1.element_sub)(this.inner, other.inner)); | ||
return new Point((0, rust_verkle_wasm_js_1.element_sub)(this.inner, other.inner)); | ||
} | ||
@@ -31,3 +31,3 @@ toBytes() { | ||
const serializableValues = values.map((value) => value.inner.toSerializableWrapper()); | ||
const inner = (0, rust_verkle_wasm_1.commit_scalar_values)(serializableValues); | ||
const inner = (0, rust_verkle_wasm_js_1.commit_scalar_values)(serializableValues); | ||
return Point.fromPointWrapper(inner); | ||
@@ -39,5 +39,5 @@ } | ||
// that saves us from doing `N` inversions. | ||
return elements.map((value) => ellipticCurveCryptographyBindings_1.ScalarField.fromScalarFieldWrapper(value.inner.mapToScalarField())); | ||
return elements.map((value) => index_js_1.ScalarField.fromScalarFieldWrapper(value.inner.mapToScalarField())); | ||
} | ||
exports.batchMapToScalarField = batchMapToScalarField; | ||
//# sourceMappingURL=point.js.map |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
export declare class BaseField extends Field { | ||
@@ -3,0 +3,0 @@ constructor(value: bigint); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseField = void 0; | ||
const field_1 = require("./field"); | ||
const field_js_1 = require("./field.js"); | ||
// The modulus that defines the basefield of the bandersnatch curve | ||
const MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513n; | ||
const Q_MIN_ONE_DIV_2 = (MODULUS - 1n) / 2n; | ||
class BaseField extends field_1.Field { | ||
class BaseField extends field_js_1.Field { | ||
constructor(value) { | ||
@@ -10,0 +10,0 @@ super(value, MODULUS); |
@@ -1,3 +0,3 @@ | ||
export { BaseField } from './baseField'; | ||
export { ScalarField } from './scalarField'; | ||
export { BaseField } from './baseField.js'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScalarField = exports.BaseField = void 0; | ||
var baseField_1 = require("./baseField"); | ||
Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return baseField_1.BaseField; } }); | ||
var scalarField_1 = require("./scalarField"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return scalarField_1.ScalarField; } }); | ||
var baseField_js_1 = require("./baseField.js"); | ||
Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return baseField_js_1.BaseField; } }); | ||
var scalarField_js_1 = require("./scalarField.js"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return scalarField_js_1.ScalarField; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
export declare class ScalarField extends Field { | ||
@@ -3,0 +3,0 @@ constructor(value: bigint); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScalarField = void 0; | ||
const field_1 = require("./field"); | ||
const field_js_1 = require("./field.js"); | ||
// The modulus that defines the scalar of the bandersnatch curve | ||
const MODULUS = 13108968793781547619861935127046491459309155893440570251786403306729687672801n; | ||
const Q_MIN_ONE_DIV_2 = (MODULUS - 1n) / 2n; | ||
class ScalarField extends field_1.Field { | ||
class ScalarField extends field_js_1.Field { | ||
constructor(value) { | ||
@@ -10,0 +10,0 @@ super(value, MODULUS); |
@@ -1,2 +0,2 @@ | ||
export { ScalarField } from './scalarField'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScalarField = void 0; | ||
var scalarField_1 = require("./scalarField"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return scalarField_1.ScalarField; } }); | ||
var scalarField_js_1 = require("./scalarField.js"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return scalarField_js_1.ScalarField; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { FrWrapper as ScalarFieldWrapper } from '../wasm/rust_verkle_wasm'; | ||
import { FrWrapper as ScalarFieldWrapper } from '../wasm/rust_verkle_wasm.js'; | ||
export declare class ScalarField { | ||
@@ -3,0 +3,0 @@ inner: ScalarFieldWrapper; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScalarField = void 0; | ||
const rust_verkle_wasm_1 = require("../wasm/rust_verkle_wasm"); | ||
const rust_verkle_wasm_js_1 = require("../wasm/rust_verkle_wasm.js"); | ||
class ScalarField { | ||
@@ -10,6 +10,6 @@ constructor(value) { | ||
static fromBytes(bytes) { | ||
return new ScalarField(rust_verkle_wasm_1.FrWrapper.fromBytes(bytes)); | ||
return new ScalarField(rust_verkle_wasm_js_1.FrWrapper.fromBytes(bytes)); | ||
} | ||
static fromDecimalString(value) { | ||
return new ScalarField(rust_verkle_wasm_1.FrWrapper.fromDecimalString(value)); | ||
return new ScalarField(rust_verkle_wasm_js_1.FrWrapper.fromDecimalString(value)); | ||
} | ||
@@ -20,6 +20,6 @@ static fromScalarFieldWrapper(inner) { | ||
add(other) { | ||
return new ScalarField((0, rust_verkle_wasm_1.fr_add)(this.inner, other.inner)); | ||
return new ScalarField((0, rust_verkle_wasm_js_1.fr_add)(this.inner, other.inner)); | ||
} | ||
sub(other) { | ||
return new ScalarField((0, rust_verkle_wasm_1.fr_sub)(this.inner, other.inner)); | ||
return new ScalarField((0, rust_verkle_wasm_js_1.fr_sub)(this.inner, other.inner)); | ||
} | ||
@@ -26,0 +26,0 @@ toBytes() { |
@@ -1,3 +0,4 @@ | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index'; | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index'; | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index.js'; | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index.js'; | ||
export { Context as VerkleFFI, getTreeKey, getTreeKeyHash } from './verkleFFIBindings/index.js'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.batchMapToScalarField = exports.commitToPoly = exports.Point = exports.ScalarField = void 0; | ||
exports.getTreeKeyHash = exports.getTreeKey = exports.VerkleFFI = exports.batchMapToScalarField = exports.commitToPoly = exports.Point = exports.ScalarField = void 0; | ||
// Export ScalarField | ||
var index_1 = require("./ellipticCurveCryptographyBindings/index"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return index_1.ScalarField; } }); | ||
var index_js_1 = require("./ellipticCurveCryptographyBindings/index.js"); | ||
Object.defineProperty(exports, "ScalarField", { enumerable: true, get: function () { return index_js_1.ScalarField; } }); | ||
// Exports the banderwagon Point class. This is used predominantly for | ||
@@ -14,6 +14,10 @@ // representing commitments. | ||
// to scalars so that one can commit to them using commitToPoly. | ||
var index_2 = require("./banderwagon_bindings/index"); | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return index_2.Point; } }); | ||
Object.defineProperty(exports, "commitToPoly", { enumerable: true, get: function () { return index_2.commitToPoly; } }); | ||
Object.defineProperty(exports, "batchMapToScalarField", { enumerable: true, get: function () { return index_2.batchMapToScalarField; } }); | ||
var index_js_2 = require("./banderwagon_bindings/index.js"); | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return index_js_2.Point; } }); | ||
Object.defineProperty(exports, "commitToPoly", { enumerable: true, get: function () { return index_js_2.commitToPoly; } }); | ||
Object.defineProperty(exports, "batchMapToScalarField", { enumerable: true, get: function () { return index_js_2.batchMapToScalarField; } }); | ||
var index_js_3 = require("./verkleFFIBindings/index.js"); | ||
Object.defineProperty(exports, "VerkleFFI", { enumerable: true, get: function () { return index_js_3.Context; } }); | ||
Object.defineProperty(exports, "getTreeKey", { enumerable: true, get: function () { return index_js_3.getTreeKey; } }); | ||
Object.defineProperty(exports, "getTreeKeyHash", { enumerable: true, get: function () { return index_js_3.getTreeKeyHash; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,4 @@ | ||
import { Context } from '../wasm/rust_verkle_wasm'; | ||
import { Context } from '../wasm/rust_verkle_wasm.js'; | ||
export declare function getTreeKey(context: Context, address: Uint8Array, treeIndex: Uint8Array, subIndex: number): Uint8Array; | ||
export declare function getTreeKeyHash(context: Context, address: Uint8Array, treeIndexLE: Uint8Array): Uint8Array; | ||
//# sourceMappingURL=getTreeKey.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTreeKey = void 0; | ||
exports.getTreeKeyHash = exports.getTreeKey = void 0; | ||
// This is equal to 2n + 256n * 64n. | ||
@@ -91,2 +91,3 @@ // | ||
} | ||
exports.getTreeKeyHash = getTreeKeyHash; | ||
function concatenateUint8Arrays(array1, array2) { | ||
@@ -93,0 +94,0 @@ const concatenatedArray = new Uint8Array(array1.length + array2.length); |
@@ -1,6 +0,6 @@ | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm'; | ||
import { getTreeKey } from './getTreeKey'; | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm.js'; | ||
import { getTreeKey, getTreeKeyHash } from './getTreeKey.js'; | ||
type Scalar = Uint8Array; | ||
type Commitment = Uint8Array; | ||
export { Scalar, Commitment, Context, zeroCommitment, getTreeKey, }; | ||
export { Scalar, Commitment, Context, zeroCommitment, getTreeKey, getTreeKeyHash, }; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTreeKey = exports.zeroCommitment = exports.Context = void 0; | ||
const rust_verkle_wasm_1 = require("../wasm/rust_verkle_wasm"); | ||
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return rust_verkle_wasm_1.Context; } }); | ||
Object.defineProperty(exports, "zeroCommitment", { enumerable: true, get: function () { return rust_verkle_wasm_1.zeroCommitment; } }); | ||
const getTreeKey_1 = require("./getTreeKey"); | ||
Object.defineProperty(exports, "getTreeKey", { enumerable: true, get: function () { return getTreeKey_1.getTreeKey; } }); | ||
exports.getTreeKeyHash = exports.getTreeKey = exports.zeroCommitment = exports.Context = void 0; | ||
const rust_verkle_wasm_js_1 = require("../wasm/rust_verkle_wasm.js"); | ||
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return rust_verkle_wasm_js_1.Context; } }); | ||
Object.defineProperty(exports, "zeroCommitment", { enumerable: true, get: function () { return rust_verkle_wasm_js_1.zeroCommitment; } }); | ||
const getTreeKey_js_1 = require("./getTreeKey.js"); | ||
Object.defineProperty(exports, "getTreeKey", { enumerable: true, get: function () { return getTreeKey_js_1.getTreeKey; } }); | ||
Object.defineProperty(exports, "getTreeKeyHash", { enumerable: true, get: function () { return getTreeKey_js_1.getTreeKeyHash; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
export { Point } from './point'; | ||
export { commitToPoly, batchMapToScalarField } from './point'; | ||
export { Point } from './point.js'; | ||
export { commitToPoly, batchMapToScalarField } from './point.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export { Point } from './point'; | ||
export { commitToPoly, batchMapToScalarField } from './point'; | ||
export { Point } from './point.js'; | ||
export { commitToPoly, batchMapToScalarField } from './point.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { ElementWrapper as PointWrapper } from '../wasm/rust_verkle_wasm'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings'; | ||
import { ElementWrapper as PointWrapper } from '../wasm/rust_verkle_wasm.js'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings/index.js'; | ||
export declare class Point { | ||
@@ -4,0 +4,0 @@ inner: PointWrapper; |
@@ -1,3 +0,3 @@ | ||
import { ElementWrapper as PointWrapper, element_add, element_sub, commit_scalar_values, } from '../wasm/rust_verkle_wasm'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings'; | ||
import { ElementWrapper as PointWrapper, element_add, element_sub, commit_scalar_values, } from '../wasm/rust_verkle_wasm.js'; | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings/index.js'; | ||
export class Point { | ||
@@ -4,0 +4,0 @@ constructor(inner) { |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
export declare class BaseField extends Field { | ||
@@ -3,0 +3,0 @@ constructor(value: bigint); |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
// The modulus that defines the basefield of the bandersnatch curve | ||
@@ -3,0 +3,0 @@ const MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513n; |
@@ -1,3 +0,3 @@ | ||
export { BaseField } from './baseField'; | ||
export { ScalarField } from './scalarField'; | ||
export { BaseField } from './baseField.js'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export { BaseField } from './baseField'; | ||
export { ScalarField } from './scalarField'; | ||
export { BaseField } from './baseField.js'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
export declare class ScalarField extends Field { | ||
@@ -3,0 +3,0 @@ constructor(value: bigint); |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field'; | ||
import { Field } from './field.js'; | ||
// The modulus that defines the scalar of the bandersnatch curve | ||
@@ -3,0 +3,0 @@ const MODULUS = 13108968793781547619861935127046491459309155893440570251786403306729687672801n; |
@@ -1,2 +0,2 @@ | ||
export { ScalarField } from './scalarField'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export { ScalarField } from './scalarField'; | ||
export { ScalarField } from './scalarField.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { FrWrapper as ScalarFieldWrapper } from '../wasm/rust_verkle_wasm'; | ||
import { FrWrapper as ScalarFieldWrapper } from '../wasm/rust_verkle_wasm.js'; | ||
export declare class ScalarField { | ||
@@ -3,0 +3,0 @@ inner: ScalarFieldWrapper; |
@@ -1,2 +0,2 @@ | ||
import { fr_add, fr_sub, FrWrapper as ScalarFieldWrapper, } from '../wasm/rust_verkle_wasm'; | ||
import { fr_add, fr_sub, FrWrapper as ScalarFieldWrapper, } from '../wasm/rust_verkle_wasm.js'; | ||
export class ScalarField { | ||
@@ -3,0 +3,0 @@ constructor(value) { |
@@ -1,3 +0,4 @@ | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index'; | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index'; | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index.js'; | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index.js'; | ||
export { Context as VerkleFFI, getTreeKey, getTreeKeyHash } from './verkleFFIBindings/index.js'; | ||
//# sourceMappingURL=index.d.ts.map |
// Export ScalarField | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index'; | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index.js'; | ||
// Exports the banderwagon Point class. This is used predominantly for | ||
@@ -10,3 +10,4 @@ // representing commitments. | ||
// to scalars so that one can commit to them using commitToPoly. | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index'; | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index.js'; | ||
export { Context as VerkleFFI, getTreeKey, getTreeKeyHash } from './verkleFFIBindings/index.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,4 @@ | ||
import { Context } from '../wasm/rust_verkle_wasm'; | ||
import { Context } from '../wasm/rust_verkle_wasm.js'; | ||
export declare function getTreeKey(context: Context, address: Uint8Array, treeIndex: Uint8Array, subIndex: number): Uint8Array; | ||
export declare function getTreeKeyHash(context: Context, address: Uint8Array, treeIndexLE: Uint8Array): Uint8Array; | ||
//# sourceMappingURL=getTreeKey.d.ts.map |
@@ -16,3 +16,3 @@ // This is equal to 2n + 256n * 64n. | ||
// Note: Tree Index is interpreted as a little endian number. | ||
function getTreeKeyHash(context, address, treeIndexLE) { | ||
export function getTreeKeyHash(context, address, treeIndexLE) { | ||
if (address.length !== 32) { | ||
@@ -19,0 +19,0 @@ throw new Error('Address must be 32 bytes'); |
@@ -1,6 +0,6 @@ | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm'; | ||
import { getTreeKey } from './getTreeKey'; | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm.js'; | ||
import { getTreeKey, getTreeKeyHash } from './getTreeKey.js'; | ||
type Scalar = Uint8Array; | ||
type Commitment = Uint8Array; | ||
export { Scalar, Commitment, Context, zeroCommitment, getTreeKey, }; | ||
export { Scalar, Commitment, Context, zeroCommitment, getTreeKey, getTreeKeyHash, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,7 +0,7 @@ | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm'; | ||
import { getTreeKey } from './getTreeKey'; | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm.js'; | ||
import { getTreeKey, getTreeKeyHash } from './getTreeKey.js'; | ||
export { Context, | ||
// This is a function that returns a zero commitment | ||
// wasm_bindgen does not seem to allow returning constants | ||
zeroCommitment, getTreeKey, }; | ||
zeroCommitment, getTreeKey, getTreeKeyHash, }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "verkle-cryptography-wasm", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Verkle Trie Crytography WASM/TypeScript Bindings", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
export { Point } from './point' | ||
export { commitToPoly, batchMapToScalarField } from './point' | ||
export { Point } from './point.js' | ||
export { commitToPoly, batchMapToScalarField } from './point.js' |
@@ -6,4 +6,4 @@ import { | ||
commit_scalar_values, | ||
} from '../wasm/rust_verkle_wasm' | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings' | ||
} from '../wasm/rust_verkle_wasm.js' | ||
import { ScalarField } from '../ellipticCurveCryptographyBindings/index.js' | ||
@@ -10,0 +10,0 @@ export class Point { |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field' | ||
import { Field } from './field.js' | ||
@@ -3,0 +3,0 @@ // The modulus that defines the basefield of the bandersnatch curve |
@@ -1,2 +0,2 @@ | ||
export { BaseField } from './baseField' | ||
export { ScalarField } from './scalarField' | ||
export { BaseField } from './baseField.js' | ||
export { ScalarField } from './scalarField.js' |
@@ -1,2 +0,2 @@ | ||
import { Field } from './field' | ||
import { Field } from './field.js' | ||
@@ -3,0 +3,0 @@ // The modulus that defines the scalar of the bandersnatch curve |
@@ -1,1 +0,1 @@ | ||
export { ScalarField } from './scalarField' | ||
export { ScalarField } from './scalarField.js' |
@@ -5,3 +5,3 @@ import { | ||
FrWrapper as ScalarFieldWrapper, | ||
} from '../wasm/rust_verkle_wasm' | ||
} from '../wasm/rust_verkle_wasm.js' | ||
@@ -8,0 +8,0 @@ export class ScalarField { |
// Export ScalarField | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index' | ||
export { ScalarField } from './ellipticCurveCryptographyBindings/index.js' | ||
@@ -11,2 +11,4 @@ // Exports the banderwagon Point class. This is used predominantly for | ||
// to scalars so that one can commit to them using commitToPoly. | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index' | ||
export { Point, commitToPoly, batchMapToScalarField } from './banderwagon_bindings/index.js' | ||
export { Context as VerkleFFI, getTreeKey, getTreeKeyHash } from './verkleFFIBindings/index.js' |
import { bytesToHex } from '@ethereumjs/util' | ||
import { beforeAll, describe, expect, test } from 'vitest' | ||
import { Context, getTreeKey } from '../verkleFFIBindings/index' | ||
import { VerkleFFI, getTreeKey, getTreeKeyHash } from '../index.js' | ||
describe('bindings', () => { | ||
let context: Context | ||
let ffi: VerkleFFI | ||
beforeAll(() => { | ||
context = new Context() | ||
ffi = new VerkleFFI() | ||
}) | ||
@@ -30,3 +30,3 @@ | ||
const key = context.getTreeKey(address, treeIndexLE, subIndex) | ||
const key = ffi.getTreeKey(address, treeIndexLE, subIndex) | ||
const keyHex = bytesToHex(key) | ||
@@ -39,2 +39,24 @@ | ||
test('getTreeKeyHash', () => { | ||
const address = new Uint8Array([ | ||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, | ||
27, 28, 29, 30, 31, 32, | ||
]) | ||
const treeIndexLE = new Uint8Array([ | ||
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, | ||
56, 57, 58, 59, 60, 61, 62, 63, 64, | ||
]) | ||
// Reverse the tree index array so it is in little endian form | ||
treeIndexLE.reverse() | ||
const hash = getTreeKeyHash(ffi, address, treeIndexLE) | ||
const hashHex = bytesToHex(hash) | ||
const expected = '0x76a014d14e338c57342cda5187775c6b75e7f0ef292e81b176c7a5a70027373a' | ||
expect(hashHex).toBe(expected) | ||
}) | ||
test('getTreeKeyJsMatchesRust', () => { | ||
@@ -53,6 +75,6 @@ const address = new Uint8Array([ | ||
const keyRust = context.getTreeKey(address, treeIndex, subIndex) | ||
const keyRust = ffi.getTreeKey(address, treeIndex, subIndex) | ||
const keyRustHex = bytesToHex(keyRust) | ||
const keyJs = getTreeKey(context, address, treeIndex, subIndex) | ||
const keyJs = getTreeKey(ffi, address, treeIndex, subIndex) | ||
const keyJsHex = bytesToHex(keyJs) | ||
@@ -71,3 +93,3 @@ | ||
const scalars = [scalar, scalar] | ||
const commitment = context.commitToScalars(scalars) | ||
const commitment = ffi.commitToScalars(scalars) | ||
@@ -87,5 +109,5 @@ const commitmentHex = bytesToHex(commitment) | ||
]) | ||
const commitment = context.commitToScalars([scalar]) | ||
const commitment = ffi.commitToScalars([scalar]) | ||
const commitmentHash = context.hashCommitment(commitment) | ||
const commitmentHash = ffi.hashCommitment(commitment) | ||
const commitmentHashHex = bytesToHex(commitmentHash) | ||
@@ -104,9 +126,9 @@ | ||
]) | ||
const commitment = context.commitToScalars([scalar]) | ||
const commitment = ffi.commitToScalars([scalar]) | ||
const commitments = [commitment, commitment] | ||
const hashes = context.hashCommitments([commitment, commitment]) | ||
const hashes = ffi.hashCommitments([commitment, commitment]) | ||
for (let i = 0; i < hashes.length; i++) { | ||
const expectedHash = context.hashCommitment(commitments[i]) | ||
const expectedHash = ffi.hashCommitment(commitments[i]) | ||
const expectedHashHex = bytesToHex(expectedHash) | ||
@@ -126,5 +148,5 @@ | ||
]) | ||
const commitment = context.commitToScalars([scalar]) | ||
const commitment = ffi.commitToScalars([scalar]) | ||
const commitmentHash = context.deprecateSerializeCommitment(commitment) | ||
const commitmentHash = ffi.deprecateSerializeCommitment(commitment) | ||
const commitmentHashHex = bytesToHex(commitmentHash) | ||
@@ -144,3 +166,3 @@ | ||
const commitmentIndex = 1 | ||
const commitment = context.scalarMulIndex(oldScalarValue, commitmentIndex) | ||
const commitment = ffi.scalarMulIndex(oldScalarValue, commitmentIndex) | ||
@@ -153,6 +175,6 @@ // Create a new scalar value to update the commitment with | ||
const expected = context.scalarMulIndex(newScalarValue, commitmentIndex) | ||
const expected = ffi.scalarMulIndex(newScalarValue, commitmentIndex) | ||
const expectedHex = bytesToHex(expected) | ||
const updatedCommitment = context.updateCommitment( | ||
const updatedCommitment = ffi.updateCommitment( | ||
commitment, | ||
@@ -174,5 +196,5 @@ commitmentIndex, | ||
// but we gave it 1 byte | ||
context.commitToScalars([scalar]) | ||
ffi.commitToScalars([scalar]) | ||
}).toThrow('Expected 32 bytes, got 1') | ||
}) | ||
}) |
import { describe, expect, test } from 'vitest' | ||
import { Field, naiveMultiInv } from '../ellipticCurveCryptography/field' | ||
import { Field, naiveMultiInv } from '../ellipticCurveCryptography/field.js' | ||
@@ -5,0 +5,0 @@ describe('modular arithmetic', () => { |
@@ -1,2 +0,2 @@ | ||
import { Context } from '../wasm/rust_verkle_wasm' | ||
import { Context } from '../wasm/rust_verkle_wasm.js' | ||
@@ -26,3 +26,3 @@ // This is equal to 2n + 256n * 64n. | ||
// Note: Tree Index is interpreted as a little endian number. | ||
function getTreeKeyHash( | ||
export function getTreeKeyHash( | ||
context: Context, | ||
@@ -29,0 +29,0 @@ address: Uint8Array, |
@@ -1,4 +0,4 @@ | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm' | ||
import { Context, zeroCommitment } from '../wasm/rust_verkle_wasm.js' | ||
import { getTreeKey } from './getTreeKey' | ||
import { getTreeKey, getTreeKeyHash } from './getTreeKey.js' | ||
@@ -20,2 +20,3 @@ // This is a 32 byte serialized field element | ||
getTreeKey, | ||
getTreeKeyHash, | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1022691
4256