Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snarkyjs-crypto

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snarkyjs-crypto - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

src/curve.bs.js

3

package.json
{
"name": "snarkyjs-crypto",
"version": "0.1.4",
"version": "0.1.5",
"scripts": {

@@ -19,2 +19,3 @@ "clean": "bsb -clean-world",

"files": [
"src/*.bs.js",
"src/*.ml*",

@@ -21,0 +22,0 @@ "bsconfig.json"

@@ -1,2 +0,2 @@

// Generated by BUCKLESCRIPT VERSION 5.0.6, PLEASE EDIT WITH CARE
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
'use strict';

@@ -16,31 +16,33 @@

var Field$1 = Field.Make(C);
var params = Params.map(Field$1[/* ofString */17], Sponge_params.Bn128[/* t */2]);
var params = Params.map(Field$1.ofString, Sponge_params.Bn128.t);
var to_the_alpha = function (x) {
var x4 = Curry._1(Field$1[/* square */20], Curry._1(Field$1[/* square */20], x));
return Curry._2(Field$1[/* * */12], x, x4);
var x4 = Curry._1(Field$1.square, Curry._1(Field$1.square, x));
return Curry._2(Field$1.$star, x, x4);
};
var Operations = Sponge.Make_operations([
Field$1[15],
Field$1[12],
Field$1[10]
]);
var $$let = Sponge.Poseidon([
[Field$1[15]],
to_the_alpha,
[
Operations[0],
Operations[3],
Operations[4]
],
8,
83
]);
var include = Sponge.Make([
$$let[3],
$$let[0],
$$let[2],
$$let[6]
]);
var hash = Curry._2(include[6], undefined, params);
if (C[/* curve */0] !== /* Bn128 */0) {
var Operations = Sponge.Make_operations({
zero: Field$1.zero,
$star: Field$1.$star,
$plus: Field$1.$plus
});
var $$let = Sponge.Poseidon({
Field: {
zero: Field$1.zero
},
to_the_alpha: to_the_alpha,
Operations: {
add_block: Operations.add_block,
apply_matrix: Operations.apply_matrix,
copy: Operations.copy
},
rounds_full: 8,
rounds_partial: 83
});
var include = Sponge.Make({
Field: $$let.Field,
add_block: $$let.add_block,
copy: $$let.copy,
block_cipher: $$let.block_cipher
});
var hash = Curry._2(include.hash, undefined, params);
if (C.curve !== /* Bn128 */0) {
throw [

@@ -55,19 +57,19 @@ Caml_builtin_exceptions.assert_failure,

}
var Group$1 = Group.BabyJubJub([
Field$1[7],
Field$1[15],
Field$1[14],
Field$1[6],
Field$1[12],
Field$1[20],
Field$1[16],
Field$1[11],
Field$1[10],
Field$1[17],
Field$1[1]
]);
var Group$1 = Group.BabyJubJub({
equal: Field$1.equal,
zero: Field$1.zero,
one: Field$1.one,
inv: Field$1.inv,
$star: Field$1.$star,
square: Field$1.square,
negate: Field$1.negate,
$neg: Field$1.$neg,
$plus: Field$1.$plus,
ofString: Field$1.ofString,
toString: Field$1.toString
});
var is_even = function (t) {
return !Field.$$BigInt[/* testBit */23](t, 0);
return !Field.$$BigInt.testBit(t, 0);
};
var $unknown$unknown = function (prim, prim$1) {
var $amp$amp = function (prim, prim$1) {
if (prim) {

@@ -79,45 +81,49 @@ return prim$1;

};
var Bool = /* module */[/* && */$unknown$unknown];
var $$let$1 = Group$1[/* Scalar */0];
var T = Signature.Make_signer(/* module */[
/* Bool */Bool,
/* Field */[
Field$1[7],
Field$1[21],
is_even
],
/* Scalar */[
$$let$1[5],
$$let$1[4],
$$let$1[22],
$$let$1[16],
$$let$1[18]
],
/* Group */[
Group$1[19],
Group$1[7],
Group$1[18],
Group$1[15],
Group$1[12]
],
/* Hash */[hash]
]);
var sign = T[/* sign */6];
var check = T[/* check */4];
var Bool = {
$amp$amp: $amp$amp
};
var $$let$1 = Group$1.Scalar;
var T = Signature.Make_signer({
Bool: Bool,
Field: {
equal: Field$1.equal,
size_in_bits: Field$1.sizeInBits,
is_even: is_even
},
Scalar: {
of_field: $$let$1.of_field,
to_field: $$let$1.to_field,
negate: $$let$1.negate,
$plus: $$let$1.$plus,
$star: $$let$1.$star
},
Group: {
add_exn: Group$1.add_exn,
to_affine_exn: Group$1.to_affine_exn,
scale: Group$1.scale,
one: Group$1.one,
negate: Group$1.negate
},
Hash: {
hash: hash
}
});
var sign = T.sign;
var check = T.check;
var toJSON = function (param) {
return /* array */[
Curry._1(Field$1[/* toString */1], param[0]),
Curry._1(Group$1[/* Scalar */0][/* toString */7], param[1])
Curry._1(Field$1.toString, param[0]),
Curry._1(Group$1.Scalar.toString, param[1])
];
};
var Signature$1 = /* module */[
/* check */check,
/* toJSON */toJSON
];
var ofPrivateKey = T[/* Public_key */2][/* of_private_key */0];
var toJSON$1 = Group$1[/* toJSON */20];
var PublicKey = /* module */[
/* ofPrivateKey */ofPrivateKey,
/* toJSON */toJSON$1
];
var Signature$1 = {
check: check,
toJSON: toJSON
};
var ofPrivateKey = T.Public_key.of_private_key;
var toJSON$1 = Group$1.toJSON;
var PublicKey = {
ofPrivateKey: ofPrivateKey,
toJSON: toJSON$1
};
var bufferGet = ((b, i) => b[i]);

@@ -127,4 +133,4 @@ var randomBytes = ((x) => crypto.randomBytes(x));

var arr = Curry._1(randomBytes, 31);
var eight = Curry._1(Field.$$BigInt[/* ofInt */20], 8);
var _acc = Curry._1(Field.$$BigInt[/* ofInt */20], 0);
var eight = Curry._1(Field.$$BigInt.ofInt, 8);
var _acc = Curry._1(Field.$$BigInt.ofInt, 0);
var _i = 0;

@@ -137,5 +143,5 @@ while(true) {

} else {
var acc$1 = Curry._2(Field.$$BigInt[/* shiftLeft */11], acc, eight);
var acc$1 = Curry._2(Field.$$BigInt.shiftLeft, acc, eight);
_i = i + 1 | 0;
_acc = Curry._2(Field.$$BigInt[/* logOr */14], acc$1, Curry._1(Field.$$BigInt[/* ofInt */20], Curry._2(bufferGet, arr, i)));
_acc = Curry._2(Field.$$BigInt.logOr, acc$1, Curry._1(Field.$$BigInt.ofInt, Curry._2(bufferGet, arr, i)));
continue ;

@@ -146,56 +152,58 @@ }

var toJSON$2 = function (t) {
return Curry._1(Field.$$BigInt[/* toString */21], t);
return Curry._1(Field.$$BigInt.toString, t);
};
var equal = Field$1[/* equal */7];
var equal = Field$1.equal;
var hash$1 = Curry.__1(hash);
var MerkleTree = Merkle_tree.Make(/* module */[
/* equal */equal,
/* hash */hash$1
]);
var $$let$2 = MerkleTree[6];
return /* module */[
/* Field */[
Field$1[8],
Field$1[7],
Field$1[12],
Field$1[10],
Field$1[11],
Field$1[13],
Field$1[4],
Field$1[2],
Field$1[3],
Field$1[9],
Field$1[16],
Field$1[5],
Field$1[20],
Field$1[14],
Field$1[15],
Field$1[17],
Field$1[18],
Field$1[1]
],
/* Hash */[hash],
/* MerkleTree */[
[
$$let$2[2],
$$let$2[4]
],
MerkleTree[8],
MerkleTree[3],
MerkleTree[4]
],
/* Group */[
Group$1[17],
Group$1[16]
],
/* Schnorr */[
[
create,
toJSON$2
],
PublicKey,
Signature$1,
sign
]
];
var MerkleTree = Merkle_tree.Make({
equal: equal,
hash: hash$1
});
var $$let$2 = MerkleTree.MembershipProof;
return {
Field: {
$eq: Field$1.$eq,
equal: Field$1.equal,
$star: Field$1.$star,
$plus: Field$1.$plus,
$neg: Field$1.$neg,
$slash: Field$1.$slash,
mul: Field$1.mul,
add: Field$1.add,
sub: Field$1.sub,
div: Field$1.div,
negate: Field$1.negate,
invert: Field$1.invert,
square: Field$1.square,
one: Field$1.one,
zero: Field$1.zero,
ofString: Field$1.ofString,
ofInt: Field$1.ofInt,
toString: Field$1.toString
},
Hash: {
hash: hash
},
MerkleTree: {
MembershipProof: {
create: $$let$2.create,
check: $$let$2.check
},
ofArray: MerkleTree.ofArray,
root: MerkleTree.root,
depth: MerkleTree.depth
},
Group: {
toAffine: Group$1.toAffine,
ofAffine: Group$1.ofAffine
},
Schnorr: {
PrivateKey: {
create: create,
toJSON: toJSON$2
},
PublicKey: PublicKey,
Signature: Signature$1,
sign: sign
}
};
}

@@ -206,32 +214,32 @@

PrivateKey: {
create: M[/* Schnorr */4][/* PrivateKey */0][/* create */0],
toJSON: M[/* Schnorr */4][/* PrivateKey */0][/* toJSON */1]
create: M.Schnorr.PrivateKey.create,
toJSON: M.Schnorr.PrivateKey.toJSON
},
PublicKey: {
ofPrivateKey: M[/* Schnorr */4][/* PublicKey */1][/* ofPrivateKey */0],
toJSON: M[/* Schnorr */4][/* PublicKey */1][/* toJSON */1]
ofPrivateKey: M.Schnorr.PublicKey.ofPrivateKey,
toJSON: M.Schnorr.PublicKey.toJSON
},
Signature: {
check: M[/* Schnorr */4][/* Signature */2][/* check */0],
toJSON: M[/* Schnorr */4][/* Signature */2][/* toJSON */1]
check: M.Schnorr.Signature.check,
toJSON: M.Schnorr.Signature.toJSON
},
sign: M[/* Schnorr */4][/* sign */3]
sign: M.Schnorr.sign
};
var field = {
equal: M[/* Field */0][/* equal */1],
add: M[/* Field */0][/* add */7],
mul: M[/* Field */0][/* mul */6],
sub: M[/* Field */0][/* sub */8],
div: M[/* Field */0][/* div */9],
ofInt: M[/* Field */0][/* ofInt */16],
ofString: M[/* Field */0][/* ofString */15],
toString: M[/* Field */0][/* toString */17],
square: M[/* Field */0][/* square */12],
invert: M[/* Field */0][/* invert */11],
negate: M[/* Field */0][/* negate */10],
zero: M[/* Field */0][/* zero */14],
one: M[/* Field */0][/* one */13]
equal: M.Field.equal,
add: M.Field.add,
mul: M.Field.mul,
sub: M.Field.sub,
div: M.Field.div,
ofInt: M.Field.ofInt,
ofString: M.Field.ofString,
toString: M.Field.toString,
square: M.Field.square,
invert: M.Field.invert,
negate: M.Field.negate,
zero: M.Field.zero,
one: M.Field.one
};
var hash = {
hash: M[/* Hash */1][/* hash */0]
hash: M.Hash.hash
};

@@ -246,3 +254,3 @@ var of_obj = function (p) {

create: (function (t, i) {
var param = Curry._2(M[/* MerkleTree */2][/* MembershipProof */0][/* create */0], t, i);
var param = Curry._2(M.MerkleTree.MembershipProof.create, t, i);
return {

@@ -254,9 +262,9 @@ index: param[/* index */0],

check: (function (p, r, h) {
return Curry._3(M[/* MerkleTree */2][/* MembershipProof */0][/* check */1], of_obj(p), r, h);
return Curry._3(M.MerkleTree.MembershipProof.check, of_obj(p), r, h);
})
};
var merkle_tree = {
ofArray: M[/* MerkleTree */2][/* ofArray */1],
depth: M[/* MerkleTree */2][/* depth */3],
root: M[/* MerkleTree */2][/* root */2],
ofArray: M.MerkleTree.ofArray,
depth: M.MerkleTree.depth,
root: M.MerkleTree.root,
MembershipProof: membership_proof

@@ -270,3 +278,3 @@ };

Group: {
toAffine: M[/* Group */3][/* toAffine */0]
toAffine: M.Group.toAffine
}

@@ -276,59 +284,63 @@ };

var C = /* module */[/* curve : Bn128 */0];
var C = {
curve: /* Bn128 */0
};
var Field$1 = Field.Make(C);
var params = Params.map(Field$1[/* ofString */17], Sponge_params.Bn128[/* t */2]);
var params = Params.map(Field$1.ofString, Sponge_params.Bn128.t);
function to_the_alpha(x) {
var x4 = Curry._1(Field$1[/* square */20], Curry._1(Field$1[/* square */20], x));
return Curry._2(Field$1[/* * */12], x, x4);
var x4 = Curry._1(Field$1.square, Curry._1(Field$1.square, x));
return Curry._2(Field$1.$star, x, x4);
}
var Operations = Sponge.Make_operations([
Field$1[15],
Field$1[12],
Field$1[10]
]);
var Operations = Sponge.Make_operations({
zero: Field$1.zero,
$star: Field$1.$star,
$plus: Field$1.$plus
});
var $$let = Sponge.Poseidon([
[Field$1[15]],
to_the_alpha,
[
Operations[0],
Operations[3],
Operations[4]
],
8,
83
]);
var $$let = Sponge.Poseidon({
Field: {
zero: Field$1.zero
},
to_the_alpha: to_the_alpha,
Operations: {
add_block: Operations.add_block,
apply_matrix: Operations.apply_matrix,
copy: Operations.copy
},
rounds_full: 8,
rounds_partial: 83
});
var include = Sponge.Make([
$$let[3],
$$let[0],
$$let[2],
$$let[6]
]);
var include = Sponge.Make({
Field: $$let.Field,
add_block: $$let.add_block,
copy: $$let.copy,
block_cipher: $$let.block_cipher
});
var hash = Curry._2(include[6], undefined, params);
var hash = Curry._2(include.hash, undefined, params);
var Group$1 = Group.BabyJubJub([
Field$1[7],
Field$1[15],
Field$1[14],
Field$1[6],
Field$1[12],
Field$1[20],
Field$1[16],
Field$1[11],
Field$1[10],
Field$1[17],
Field$1[1]
]);
var Group$1 = Group.BabyJubJub({
equal: Field$1.equal,
zero: Field$1.zero,
one: Field$1.one,
inv: Field$1.inv,
$star: Field$1.$star,
square: Field$1.square,
negate: Field$1.negate,
$neg: Field$1.$neg,
$plus: Field$1.$plus,
ofString: Field$1.ofString,
toString: Field$1.toString
});
function is_even(t) {
return !Field.$$BigInt[/* testBit */23](t, 0);
return !Field.$$BigInt.testBit(t, 0);
}
function $unknown$unknown(prim, prim$1) {
function $amp$amp(prim, prim$1) {
if (prim) {

@@ -341,54 +353,58 @@ return prim$1;

var Bool = /* module */[/* && */$unknown$unknown];
var Bool = {
$amp$amp: $amp$amp
};
var $$let$1 = Group$1[/* Scalar */0];
var $$let$1 = Group$1.Scalar;
var T = Signature.Make_signer(/* module */[
/* Bool */Bool,
/* Field */[
Field$1[7],
Field$1[21],
is_even
],
/* Scalar */[
$$let$1[5],
$$let$1[4],
$$let$1[22],
$$let$1[16],
$$let$1[18]
],
/* Group */[
Group$1[19],
Group$1[7],
Group$1[18],
Group$1[15],
Group$1[12]
],
/* Hash */[hash]
]);
var T = Signature.Make_signer({
Bool: Bool,
Field: {
equal: Field$1.equal,
size_in_bits: Field$1.sizeInBits,
is_even: is_even
},
Scalar: {
of_field: $$let$1.of_field,
to_field: $$let$1.to_field,
negate: $$let$1.negate,
$plus: $$let$1.$plus,
$star: $$let$1.$star
},
Group: {
add_exn: Group$1.add_exn,
to_affine_exn: Group$1.to_affine_exn,
scale: Group$1.scale,
one: Group$1.one,
negate: Group$1.negate
},
Hash: {
hash: hash
}
});
var sign = T[/* sign */6];
var sign = T.sign;
var check = T[/* check */4];
var check = T.check;
function toJSON(param) {
return /* array */[
Curry._1(Field$1[/* toString */1], param[0]),
Curry._1(Group$1[/* Scalar */0][/* toString */7], param[1])
Curry._1(Field$1.toString, param[0]),
Curry._1(Group$1.Scalar.toString, param[1])
];
}
var Signature$1 = /* module */[
/* check */check,
/* toJSON */toJSON
];
var Signature$1 = {
check: check,
toJSON: toJSON
};
var ofPrivateKey = T[/* Public_key */2][/* of_private_key */0];
var ofPrivateKey = T.Public_key.of_private_key;
var toJSON$1 = Group$1[/* toJSON */20];
var toJSON$1 = Group$1.toJSON;
var PublicKey = /* module */[
/* ofPrivateKey */ofPrivateKey,
/* toJSON */toJSON$1
];
var PublicKey = {
ofPrivateKey: ofPrivateKey,
toJSON: toJSON$1
};

@@ -401,4 +417,4 @@ var bufferGet = ((b, i) => b[i]);

var arr = Curry._1(randomBytes, 31);
var eight = Curry._1(Field.$$BigInt[/* ofInt */20], 8);
var _acc = Curry._1(Field.$$BigInt[/* ofInt */20], 0);
var eight = Curry._1(Field.$$BigInt.ofInt, 8);
var _acc = Curry._1(Field.$$BigInt.ofInt, 0);
var _i = 0;

@@ -411,5 +427,5 @@ while(true) {

} else {
var acc$1 = Curry._2(Field.$$BigInt[/* shiftLeft */11], acc, eight);
var acc$1 = Curry._2(Field.$$BigInt.shiftLeft, acc, eight);
_i = i + 1 | 0;
_acc = Curry._2(Field.$$BigInt[/* logOr */14], acc$1, Curry._1(Field.$$BigInt[/* ofInt */20], Curry._2(bufferGet, arr, i)));
_acc = Curry._2(Field.$$BigInt.logOr, acc$1, Curry._1(Field.$$BigInt.ofInt, Curry._2(bufferGet, arr, i)));
continue ;

@@ -421,71 +437,73 @@ }

function toJSON$2(t) {
return Curry._1(Field.$$BigInt[/* toString */21], t);
return Curry._1(Field.$$BigInt.toString, t);
}
var equal = Field$1[/* equal */7];
var equal = Field$1.equal;
var hash$1 = Curry.__1(hash);
var MerkleTree = Merkle_tree.Make(/* module */[
/* equal */equal,
/* hash */hash$1
]);
var MerkleTree = Merkle_tree.Make({
equal: equal,
hash: hash$1
});
var $$let$2 = MerkleTree[6];
var $$let$2 = MerkleTree.MembershipProof;
var Bn128_000 = /* Field */[
Field$1[8],
Field$1[7],
Field$1[12],
Field$1[10],
Field$1[11],
Field$1[13],
Field$1[4],
Field$1[2],
Field$1[3],
Field$1[9],
Field$1[16],
Field$1[5],
Field$1[20],
Field$1[14],
Field$1[15],
Field$1[17],
Field$1[18],
Field$1[1]
];
var Bn128_Field = {
$eq: Field$1.$eq,
equal: Field$1.equal,
$star: Field$1.$star,
$plus: Field$1.$plus,
$neg: Field$1.$neg,
$slash: Field$1.$slash,
mul: Field$1.mul,
add: Field$1.add,
sub: Field$1.sub,
div: Field$1.div,
negate: Field$1.negate,
invert: Field$1.invert,
square: Field$1.square,
one: Field$1.one,
zero: Field$1.zero,
ofString: Field$1.ofString,
ofInt: Field$1.ofInt,
toString: Field$1.toString
};
var Bn128_001 = /* Hash */[hash];
var Bn128_Hash = {
hash: hash
};
var Bn128_002 = /* MerkleTree */[
[
$$let$2[2],
$$let$2[4]
],
MerkleTree[8],
MerkleTree[3],
MerkleTree[4]
];
var Bn128_MerkleTree = {
MembershipProof: {
create: $$let$2.create,
check: $$let$2.check
},
ofArray: MerkleTree.ofArray,
root: MerkleTree.root,
depth: MerkleTree.depth
};
var Bn128_003 = /* Group */[
Group$1[17],
Group$1[16]
];
var Bn128_Group = {
toAffine: Group$1.toAffine,
ofAffine: Group$1.ofAffine
};
var Bn128_004 = /* Schnorr */[
[
create,
toJSON$2
],
PublicKey,
Signature$1,
sign
];
var Bn128_Schnorr = {
PrivateKey: {
create: create,
toJSON: toJSON$2
},
PublicKey: PublicKey,
Signature: Signature$1,
sign: sign
};
var Bn128 = /* module */[
Bn128_000,
Bn128_001,
Bn128_002,
Bn128_003,
Bn128_004
];
var Bn128 = {
Field: Bn128_Field,
Hash: Bn128_Hash,
MerkleTree: Bn128_MerkleTree,
Group: Bn128_Group,
Schnorr: Bn128_Schnorr
};

@@ -492,0 +510,0 @@ var bn128 = make_obj(Bn128);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc