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.1 to 0.1.2

src/elliptic_curve.ml

5

package.json
{
"name": "snarkyjs-crypto",
"version": "0.1.1",
"version": "0.1.2",
"scripts": {

@@ -15,5 +15,6 @@ "clean": "bsb -clean-world",

"dependencies": {
"bs-platform": "^5.0.6"
"bs-platform": "^5.0.6",
"json-bigint": "^0.3.0"
},
"main": "src/universe.bs.js"
}

343

src/universe.bs.js

@@ -6,21 +6,24 @@ // Generated by BUCKLESCRIPT VERSION 5.0.6, PLEASE EDIT WITH CARE

var Field = require("./field.bs.js");
var Group = require("./group.bs.js");
var Params = require("./params.bs.js");
var Sponge = require("./sponge.bs.js");
var Signature = require("./signature.bs.js");
var Merkle_tree = require("./merkle_tree.bs.js");
var Sponge_params = require("./sponge_params.bs.js");
var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js");
function Make(C) {
var Field$1 = Field.Make(C);
var params = Params.map(Field$1[/* ofString */15], Sponge_params.Bn128[/* t */2]);
var params = Params.map(Field$1[/* ofString */17], Sponge_params.Bn128[/* t */2]);
var to_the_alpha = function (x) {
var x4 = Curry._1(Field$1[/* square */17], Curry._1(Field$1[/* square */17], x));
return Curry._2(Field$1[/* * */10], x, x4);
var x4 = Curry._1(Field$1[/* square */20], Curry._1(Field$1[/* square */20], x));
return Curry._2(Field$1[/* * */12], x, x4);
};
var Operations = Sponge.Make_operations([
Field$1[13],
Field$1[10],
Field$1[8]
Field$1[15],
Field$1[12],
Field$1[10]
]);
var $$let = Sponge.Poseidon([
[Field$1[13]],
[Field$1[15]],
to_the_alpha,

@@ -42,3 +45,102 @@ [

var hash = Curry._2(include[6], undefined, params);
var equal = Field$1[/* equal */5];
if (C[/* curve */0] !== /* Bn128 */0) {
throw [
Caml_builtin_exceptions.assert_failure,
/* tuple */[
"universe.ml",
40,
11
]
];
}
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 is_even = function (t) {
return !Field.$$BigInt[/* testBit */23](t, 0);
};
var $unknown$unknown = function (prim, prim$1) {
if (prim) {
return prim$1;
} else {
return false;
}
};
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[17],
Group$1[7],
Group$1[16],
Group$1[15],
Group$1[12]
],
/* Hash */[hash]
]);
var sign = T[/* sign */6];
var check = T[/* check */4];
var toJSON = function (param) {
return /* array */[
Curry._1(Field$1[/* toString */1], param[0]),
Curry._1(Group$1[/* Scalar */0][/* toString */7], 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 */18];
var PublicKey = /* module */[
/* ofPrivateKey */ofPrivateKey,
/* toJSON */toJSON$1
];
var bufferGet = ((b, i) => b[i]);
var randomBytes = ((x) => crypto.randomBytes(x));
var create = function (param) {
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 _i = 0;
while(true) {
var i = _i;
var acc = _acc;
if (i === 31) {
return acc;
} else {
var acc$1 = Curry._2(Field.$$BigInt[/* shiftLeft */11], 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)));
continue ;
}
};
};
var toJSON$2 = function (t) {
return Curry._1(Field.$$BigInt[/* toString */21], t);
};
var equal = Field$1[/* equal */7];
var hash$1 = Curry.__1(hash);

@@ -49,22 +151,22 @@ var MerkleTree = Merkle_tree.Make(/* module */[

]);
var $$let$1 = MerkleTree[4];
var $$let$2 = MerkleTree[4];
return /* module */[
/* Field */[
Field$1[6],
Field$1[5],
Field$1[8],
Field$1[7],
Field$1[12],
Field$1[10],
Field$1[8],
Field$1[9],
Field$1[11],
Field$1[13],
Field$1[4],
Field$1[2],
Field$1[3],
Field$1[1],
Field$1[2],
Field$1[7],
Field$1[9],
Field$1[16],
Field$1[20],
Field$1[5],
Field$1[14],
Field$1[15],
Field$1[17],
Field$1[4],
Field$1[12],
Field$1[13],
Field$1[15],
Field$1[16]
Field$1[18]
],

@@ -74,6 +176,15 @@ /* Hash */[hash],

[
$$let$1[2],
$$let$1[4]
$$let$2[2],
$$let$2[4]
],
MerkleTree[6]
],
/* Schnorr */[
[
create,
toJSON$2
],
PublicKey,
Signature$1,
sign
]

@@ -84,2 +195,17 @@ ];

function make_obj(M) {
var schnorr = {
PrivateKey: {
create: M[/* Schnorr */3][/* PrivateKey */0][/* create */0],
toJSON: M[/* Schnorr */3][/* PrivateKey */0][/* toJSON */1]
},
PublicKey: {
ofPrivateKey: M[/* Schnorr */3][/* PublicKey */1][/* ofPrivateKey */0],
toJSON: M[/* Schnorr */3][/* PublicKey */1][/* toJSON */1]
},
Signature: {
check: M[/* Schnorr */3][/* Signature */2][/* check */0],
toJSON: M[/* Schnorr */3][/* Signature */2][/* toJSON */1]
},
sign: M[/* Schnorr */3][/* sign */3]
};
var field = {

@@ -127,3 +253,4 @@ equal: M[/* Field */0][/* equal */1],

Hash: hash,
MerkleTree: merkle_tree
MerkleTree: merkle_tree,
Schnorr: schnorr
};

@@ -136,17 +263,17 @@ }

var params = Params.map(Field$1[/* ofString */15], Sponge_params.Bn128[/* t */2]);
var params = Params.map(Field$1[/* ofString */17], Sponge_params.Bn128[/* t */2]);
function to_the_alpha(x) {
var x4 = Curry._1(Field$1[/* square */17], Curry._1(Field$1[/* square */17], x));
return Curry._2(Field$1[/* * */10], x, x4);
var x4 = Curry._1(Field$1[/* square */20], Curry._1(Field$1[/* square */20], x));
return Curry._2(Field$1[/* * */12], x, x4);
}
var Operations = Sponge.Make_operations([
Field$1[13],
Field$1[10],
Field$1[8]
Field$1[15],
Field$1[12],
Field$1[10]
]);
var $$let = Sponge.Poseidon([
[Field$1[13]],
[Field$1[15]],
to_the_alpha,

@@ -171,4 +298,110 @@ [

var equal = Field$1[/* equal */5];
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]
]);
function is_even(t) {
return !Field.$$BigInt[/* testBit */23](t, 0);
}
function $unknown$unknown(prim, prim$1) {
if (prim) {
return prim$1;
} else {
return false;
}
}
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[17],
Group$1[7],
Group$1[16],
Group$1[15],
Group$1[12]
],
/* Hash */[hash]
]);
var sign = T[/* sign */6];
var check = T[/* check */4];
function toJSON(param) {
return /* array */[
Curry._1(Field$1[/* toString */1], param[0]),
Curry._1(Group$1[/* Scalar */0][/* toString */7], 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 */18];
var PublicKey = /* module */[
/* ofPrivateKey */ofPrivateKey,
/* toJSON */toJSON$1
];
var bufferGet = ((b, i) => b[i]);
var randomBytes = ((x) => crypto.randomBytes(x));
function create(param) {
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 _i = 0;
while(true) {
var i = _i;
var acc = _acc;
if (i === 31) {
return acc;
} else {
var acc$1 = Curry._2(Field.$$BigInt[/* shiftLeft */11], 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)));
continue ;
}
};
}
function toJSON$2(t) {
return Curry._1(Field.$$BigInt[/* toString */21], t);
}
var equal = Field$1[/* equal */7];
var hash$1 = Curry.__1(hash);

@@ -181,22 +414,22 @@

var $$let$1 = MerkleTree[4];
var $$let$2 = MerkleTree[4];
var Bn128_000 = /* Field */[
Field$1[6],
Field$1[5],
Field$1[8],
Field$1[7],
Field$1[12],
Field$1[10],
Field$1[8],
Field$1[9],
Field$1[11],
Field$1[13],
Field$1[4],
Field$1[2],
Field$1[3],
Field$1[1],
Field$1[2],
Field$1[7],
Field$1[9],
Field$1[16],
Field$1[20],
Field$1[5],
Field$1[14],
Field$1[15],
Field$1[17],
Field$1[4],
Field$1[12],
Field$1[13],
Field$1[15],
Field$1[16]
Field$1[18]
];

@@ -208,4 +441,4 @@

[
$$let$1[2],
$$let$1[4]
$$let$2[2],
$$let$2[4]
],

@@ -215,6 +448,17 @@ MerkleTree[6]

var Bn128_003 = /* Schnorr */[
[
create,
toJSON$2
],
PublicKey,
Signature$1,
sign
];
var Bn128 = /* module */[
Bn128_000,
Bn128_001,
Bn128_002
Bn128_002,
Bn128_003
];

@@ -224,2 +468,5 @@

var Field0 = 0;
exports.Field0 = Field0;
exports.Make = Make;

@@ -226,0 +473,0 @@ exports.make_obj = make_obj;

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

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