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

@mysten/zklogin

Package Overview
Dependencies
Maintainers
4
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/zklogin - npm Package Compare versions

Comparing version 0.0.0-experimental-20230913202735 to 0.0.0-experimental-20230913203721

6

CHANGELOG.md
# @mysten/zklogin
## 0.0.0-experimental-20230913202735
## 0.0.0-experimental-20230913203721
### Patch Changes
- 9b3ffc7d6: - removes `AddressParams` bcs struct, now address is created by using the iss bytes
- updated zklogin signature bcs struct for new camelCase fields
- d257d20ee: Improve nodejs compatibility
- Updated dependencies [fd8589806]
- @mysten/sui.js@0.0.0-experimental-20230913202735
- @mysten/sui.js@0.0.0-experimental-20230913203721

@@ -11,0 +13,0 @@ ## 0.1.3

@@ -29,3 +29,2 @@ "use strict";

var import_utils2 = require("@mysten/sui.js/utils");
var import_bcs = require("./bcs.js");
var import_jose = require("jose");

@@ -60,7 +59,8 @@ var import_utils3 = require("./utils.js");

);
const addressParamBytes = import_bcs.zkBcs.ser("AddressParams", { iss }).toBytes();
const tmp = new Uint8Array(1 + addressSeedBytesBigEndian.length + addressParamBytes.length);
const addressParamBytes = Buffer.from(iss);
const tmp = new Uint8Array(2 + addressSeedBytesBigEndian.length + addressParamBytes.length);
tmp.set([import_cryptography.SIGNATURE_SCHEME_TO_FLAG.Zk]);
tmp.set(addressParamBytes, 1);
tmp.set(addressSeedBytesBigEndian, 1 + addressParamBytes.length);
tmp.set([addressParamBytes.length], 1);
tmp.set(addressParamBytes, 2);
tmp.set(addressSeedBytesBigEndian, 2 + addressParamBytes.length);
return (0, import_utils2.normalizeSuiAddress)(

@@ -67,0 +67,0 @@ (0, import_utils.bytesToHex)((0, import_blake2b.blake2b)(tmp, { dkLen: 32 })).slice(0, import_utils2.SUI_ADDRESS_LENGTH * 2)

import { BCS } from '@mysten/bcs';
export declare const zkBcs: BCS;
type Claim = {
name: string;
value_base64: string;
index_mod_4: number;
type ProofPoints = {
a: string[];
b: string[][];
c: string[];
};
export interface ProofPoints {
pi_a: string[];
pi_b: string[][];
pi_c: string[];
}
type IssBase64 = {
value: string;
indexMod4: number;
};
export interface ZkSignatureInputs {
proof_points: ProofPoints;
address_seed: string;
claims: Claim[];
header_base64: string;
proofPoints: ProofPoints;
issBase64Details: IssBase64;
headerBase64: string;
addressSeed: string;
}

@@ -19,0 +18,0 @@ export interface ZkSignature {

@@ -29,31 +29,26 @@ "use strict";

const zkBcs = new import_bcs.BCS(import_bcs2.bcs);
zkBcs.registerStructType("AddressParams", {
iss: import_bcs.BCS.STRING
});
zkBcs.registerStructType("ZkClaim", {
name: import_bcs.BCS.STRING,
value_base64: import_bcs.BCS.STRING,
index_mod_4: import_bcs.BCS.U8
});
zkBcs.registerStructType("ZkSignature", {
zkBcs.registerStructType("ZkloginSignature", {
inputs: {
proof_points: {
pi_a: [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING],
pi_b: [import_bcs.BCS.VECTOR, [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING]],
pi_c: [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING]
proofPoints: {
a: [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING],
b: [import_bcs.BCS.VECTOR, [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING]],
c: [import_bcs.BCS.VECTOR, import_bcs.BCS.STRING]
},
address_seed: import_bcs.BCS.STRING,
claims: [import_bcs.BCS.VECTOR, "ZkClaim"],
header_base64: import_bcs.BCS.STRING
issBase64Details: {
value: import_bcs.BCS.STRING,
indexMod4: import_bcs.BCS.U8
},
headerBase64: import_bcs.BCS.STRING,
addressSeed: import_bcs.BCS.STRING
},
max_epoch: import_bcs.BCS.U64,
user_signature: [import_bcs.BCS.VECTOR, import_bcs.BCS.U8]
maxEpoch: import_bcs.BCS.U64,
userSignature: [import_bcs.BCS.VECTOR, import_bcs.BCS.U8]
});
function getZkSignatureBytes({ inputs, maxEpoch, userSignature }) {
return zkBcs.ser(
"ZkSignature",
"ZkloginSignature",
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === "string" ? (0, import_bcs.fromB64)(userSignature) : userSignature
maxEpoch,
userSignature: typeof userSignature === "string" ? (0, import_bcs.fromB64)(userSignature) : userSignature
},

@@ -60,0 +55,0 @@ { maxSize: 2048 }

export { computeZkAddress, jwtToAddress } from './address.js';
export type { ComputeZKAddressOptions } from './address.js';
export { getZkSignature } from './bcs.js';
export type { ZkSignatureInputs } from './bcs.js';
export { poseidonHash } from './poseidon.js';
export { generateNonce, generateRandomness } from './nonce.js';
export { hashASCIIStrToField, genAddressSeed } from './utils.js';

@@ -5,3 +5,2 @@ import { bytesToHex } from "@noble/hashes/utils";

import { SUI_ADDRESS_LENGTH, normalizeSuiAddress } from "@mysten/sui.js/utils";
import { zkBcs } from "./bcs.js";
import { decodeJwt } from "jose";

@@ -36,7 +35,8 @@ import { genAddressSeed, toBufferBE } from "./utils.js";

);
const addressParamBytes = zkBcs.ser("AddressParams", { iss }).toBytes();
const tmp = new Uint8Array(1 + addressSeedBytesBigEndian.length + addressParamBytes.length);
const addressParamBytes = Buffer.from(iss);
const tmp = new Uint8Array(2 + addressSeedBytesBigEndian.length + addressParamBytes.length);
tmp.set([SIGNATURE_SCHEME_TO_FLAG.Zk]);
tmp.set(addressParamBytes, 1);
tmp.set(addressSeedBytesBigEndian, 1 + addressParamBytes.length);
tmp.set([addressParamBytes.length], 1);
tmp.set(addressParamBytes, 2);
tmp.set(addressSeedBytesBigEndian, 2 + addressParamBytes.length);
return normalizeSuiAddress(

@@ -43,0 +43,0 @@ bytesToHex(blake2b(tmp, { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2)

import { BCS } from '@mysten/bcs';
export declare const zkBcs: BCS;
type Claim = {
name: string;
value_base64: string;
index_mod_4: number;
type ProofPoints = {
a: string[];
b: string[][];
c: string[];
};
export interface ProofPoints {
pi_a: string[];
pi_b: string[][];
pi_c: string[];
}
type IssBase64 = {
value: string;
indexMod4: number;
};
export interface ZkSignatureInputs {
proof_points: ProofPoints;
address_seed: string;
claims: Claim[];
header_base64: string;
proofPoints: ProofPoints;
issBase64Details: IssBase64;
headerBase64: string;
addressSeed: string;
}

@@ -19,0 +18,0 @@ export interface ZkSignature {

@@ -5,31 +5,26 @@ import { BCS, fromB64, toB64 } from "@mysten/bcs";

const zkBcs = new BCS(bcs);
zkBcs.registerStructType("AddressParams", {
iss: BCS.STRING
});
zkBcs.registerStructType("ZkClaim", {
name: BCS.STRING,
value_base64: BCS.STRING,
index_mod_4: BCS.U8
});
zkBcs.registerStructType("ZkSignature", {
zkBcs.registerStructType("ZkloginSignature", {
inputs: {
proof_points: {
pi_a: [BCS.VECTOR, BCS.STRING],
pi_b: [BCS.VECTOR, [BCS.VECTOR, BCS.STRING]],
pi_c: [BCS.VECTOR, BCS.STRING]
proofPoints: {
a: [BCS.VECTOR, BCS.STRING],
b: [BCS.VECTOR, [BCS.VECTOR, BCS.STRING]],
c: [BCS.VECTOR, BCS.STRING]
},
address_seed: BCS.STRING,
claims: [BCS.VECTOR, "ZkClaim"],
header_base64: BCS.STRING
issBase64Details: {
value: BCS.STRING,
indexMod4: BCS.U8
},
headerBase64: BCS.STRING,
addressSeed: BCS.STRING
},
max_epoch: BCS.U64,
user_signature: [BCS.VECTOR, BCS.U8]
maxEpoch: BCS.U64,
userSignature: [BCS.VECTOR, BCS.U8]
});
function getZkSignatureBytes({ inputs, maxEpoch, userSignature }) {
return zkBcs.ser(
"ZkSignature",
"ZkloginSignature",
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === "string" ? fromB64(userSignature) : userSignature
maxEpoch,
userSignature: typeof userSignature === "string" ? fromB64(userSignature) : userSignature
},

@@ -36,0 +31,0 @@ { maxSize: 2048 }

export { computeZkAddress, jwtToAddress } from './address.js';
export type { ComputeZKAddressOptions } from './address.js';
export { getZkSignature } from './bcs.js';
export type { ZkSignatureInputs } from './bcs.js';
export { poseidonHash } from './poseidon.js';
export { generateNonce, generateRandomness } from './nonce.js';
export { hashASCIIStrToField, genAddressSeed } from './utils.js';
{
"name": "@mysten/zklogin",
"version": "0.0.0-experimental-20230913202735",
"version": "0.0.0-experimental-20230913203721",
"description": "Utilities for interacting with zkLogin in Sui",

@@ -42,3 +42,3 @@ "license": "Apache-2.0",

"@mysten/bcs": "0.7.4",
"@mysten/sui.js": "0.0.0-experimental-20230913202735"
"@mysten/sui.js": "0.0.0-experimental-20230913203721"
},

@@ -45,0 +45,0 @@ "scripts": {

@@ -8,3 +8,2 @@ // Copyright (c) Mysten Labs, Inc.

import { SUI_ADDRESS_LENGTH, normalizeSuiAddress } from '@mysten/sui.js/utils';
import { zkBcs } from './bcs.js';
import { decodeJwt } from 'jose';

@@ -51,8 +50,8 @@ import { genAddressSeed, toBufferBE } from './utils.js';

);
const addressParamBytes = zkBcs.ser('AddressParams', { iss }).toBytes();
const tmp = new Uint8Array(1 + addressSeedBytesBigEndian.length + addressParamBytes.length);
const addressParamBytes = Buffer.from(iss);
const tmp = new Uint8Array(2 + addressSeedBytesBigEndian.length + addressParamBytes.length);
tmp.set([SIGNATURE_SCHEME_TO_FLAG.Zk]);
tmp.set(addressParamBytes, 1);
tmp.set(addressSeedBytesBigEndian, 1 + addressParamBytes.length);
tmp.set([addressParamBytes.length], 1);
tmp.set(addressParamBytes, 2);
tmp.set(addressSeedBytesBigEndian, 2 + addressParamBytes.length);

@@ -59,0 +58,0 @@ return normalizeSuiAddress(

@@ -10,29 +10,18 @@ // Copyright (c) Mysten Labs, Inc.

zkBcs.registerStructType('AddressParams', {
iss: BCS.STRING,
});
type ProofPoints = {
a: string[];
b: string[][];
c: string[];
};
zkBcs.registerStructType('ZkClaim', {
name: BCS.STRING,
value_base64: BCS.STRING,
index_mod_4: BCS.U8,
});
type Claim = {
name: string;
value_base64: string;
index_mod_4: number;
type IssBase64 = {
value: string;
indexMod4: number;
};
export interface ProofPoints {
pi_a: string[];
pi_b: string[][];
pi_c: string[];
}
export interface ZkSignatureInputs {
proof_points: ProofPoints;
address_seed: string;
claims: Claim[];
header_base64: string;
proofPoints: ProofPoints;
issBase64Details: IssBase64;
headerBase64: string;
addressSeed: string;
}

@@ -46,15 +35,18 @@

zkBcs.registerStructType('ZkSignature', {
zkBcs.registerStructType('ZkloginSignature', {
inputs: {
proof_points: {
pi_a: [BCS.VECTOR, BCS.STRING],
pi_b: [BCS.VECTOR, [BCS.VECTOR, BCS.STRING]],
pi_c: [BCS.VECTOR, BCS.STRING],
proofPoints: {
a: [BCS.VECTOR, BCS.STRING],
b: [BCS.VECTOR, [BCS.VECTOR, BCS.STRING]],
c: [BCS.VECTOR, BCS.STRING],
},
address_seed: BCS.STRING,
claims: [BCS.VECTOR, 'ZkClaim'],
header_base64: BCS.STRING,
issBase64Details: {
value: BCS.STRING,
indexMod4: BCS.U8,
},
headerBase64: BCS.STRING,
addressSeed: BCS.STRING,
},
max_epoch: BCS.U64,
user_signature: [BCS.VECTOR, BCS.U8],
maxEpoch: BCS.U64,
userSignature: [BCS.VECTOR, BCS.U8],
});

@@ -65,7 +57,7 @@

.ser(
'ZkSignature',
'ZkloginSignature',
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === 'string' ? fromB64(userSignature) : userSignature,
maxEpoch,
userSignature: typeof userSignature === 'string' ? fromB64(userSignature) : userSignature,
},

@@ -72,0 +64,0 @@ { maxSize: 2048 },

@@ -8,2 +8,3 @@ // Copyright (c) Mysten Labs, Inc.

export { getZkSignature } from './bcs.js';
export type { ZkSignatureInputs } from './bcs.js';

@@ -10,0 +11,0 @@ export { poseidonHash } from './poseidon.js';

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

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