Socket
Socket
Sign inDemoInstall

@mysten/zklogin

Package Overview
Dependencies
Maintainers
4
Versions
245
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-20230829185142 to 0.0.0-experimental-20230906174457

4

./dist/cjs/index.js

@@ -25,7 +25,7 @@ "use strict";

generateNonce: () => import_nonce.generateNonce,
getZkSignature: () => import_bcs.getZkSignature,
hashASCIIStrToField: () => import_utils.hashASCIIStrToField,
hashToField: () => import_utils.hashToField,
jwtToAddress: () => import_address.jwtToAddress,
poseidonHash: () => import_poseidon.poseidonHash,
zkBcs: () => import_bcs.zkBcs
poseidonHash: () => import_poseidon.poseidonHash
});

@@ -32,0 +32,0 @@ module.exports = __toCommonJS(src_exports);

# @mysten/zklogin
## 0.0.0-experimental-20230829185142
## 0.0.0-experimental-20230906174457
### Patch Changes
- 8384490bb: Remove BCS export and introduce new getZkSignature export.
## 0.1.2
### Patch Changes
- d0750ea0f: rename pin to salt
- a82600f2d: fix nonce calculation
- Updated dependencies [24c21e1f0]
- @mysten/sui.js@0.0.0-experimental-20230829185142
- @mysten/sui.js@0.41.1

@@ -12,0 +18,0 @@ ## 0.1.1

@@ -34,3 +34,3 @@ "use strict";

const decodedJWT = (0, import_jose.decodeJwt)(jwt);
if (!decodedJWT.sub || !decodedJWT.iss || !decodedJWT.aud || !decodedJWT.email || typeof decodedJWT.email !== "string") {
if (!decodedJWT.sub || !decodedJWT.iss || !decodedJWT.aud) {
throw new Error("Missing jwt data");

@@ -37,0 +37,0 @@ }

import { BCS } from '@mysten/bcs';
export declare const zkBcs: BCS;
type Claim = {
name: string;
value_base64: string;
index_mod_4: 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;
}
export interface ZkSignature {
inputs: ZkSignatureInputs;
maxEpoch: number;
userSignature: string | Uint8Array;
}
export declare function getZkSignature({ inputs, maxEpoch, userSignature }: ZkSignature): string;
export {};

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

__export(bcs_exports, {
getZkSignature: () => getZkSignature,
zkBcs: () => zkBcs

@@ -26,2 +27,3 @@ });

var import_bcs = require("@mysten/bcs");
var import_cryptography = require("@mysten/sui.js/cryptography");
var import_bcs2 = require("@mysten/sui.js/bcs");

@@ -52,2 +54,20 @@ const zkBcs = new import_bcs.BCS(import_bcs2.bcs);

});
function getZkSignatureBytes({ inputs, maxEpoch, userSignature }) {
return zkBcs.ser(
"ZkSignature",
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === "string" ? (0, import_bcs.fromB64)(userSignature) : userSignature
},
{ maxSize: 2048 }
).toBytes();
}
function getZkSignature({ inputs, maxEpoch, userSignature }) {
const bytes = getZkSignatureBytes({ inputs, maxEpoch, userSignature });
const signatureBytes = new Uint8Array(bytes.length + 1);
signatureBytes.set([import_cryptography.SIGNATURE_SCHEME_TO_FLAG["Zk"]]);
signatureBytes.set(bytes, 1);
return (0, import_bcs.toB64)(signatureBytes);
}
//# sourceMappingURL=bcs.js.map
export { computeZkAddress, jwtToAddress } from './address.js';
export type { ComputeZKAddressOptions } from './address.js';
export { zkBcs } from './bcs.js';
export { getZkSignature } from './bcs.js';
export { poseidonHash } from './poseidon.js';
export { generateNonce } from './nonce.js';
export { convertBase, hashToField, hashASCIIStrToField, genAddressSeed } from './utils.js';

@@ -25,7 +25,7 @@ "use strict";

generateNonce: () => import_nonce.generateNonce,
getZkSignature: () => import_bcs.getZkSignature,
hashASCIIStrToField: () => import_utils.hashASCIIStrToField,
hashToField: () => import_utils.hashToField,
jwtToAddress: () => import_address.jwtToAddress,
poseidonHash: () => import_poseidon.poseidonHash,
zkBcs: () => import_bcs.zkBcs
poseidonHash: () => import_poseidon.poseidonHash
});

@@ -32,0 +32,0 @@ module.exports = __toCommonJS(src_exports);

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

const decodedJWT = decodeJwt(jwt);
if (!decodedJWT.sub || !decodedJWT.iss || !decodedJWT.aud || !decodedJWT.email || typeof decodedJWT.email !== "string") {
if (!decodedJWT.sub || !decodedJWT.iss || !decodedJWT.aud) {
throw new Error("Missing jwt data");

@@ -13,0 +13,0 @@ }

import { BCS } from '@mysten/bcs';
export declare const zkBcs: BCS;
type Claim = {
name: string;
value_base64: string;
index_mod_4: 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;
}
export interface ZkSignature {
inputs: ZkSignatureInputs;
maxEpoch: number;
userSignature: string | Uint8Array;
}
export declare function getZkSignature({ inputs, maxEpoch, userSignature }: ZkSignature): string;
export {};

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

import { BCS } from "@mysten/bcs";
import { BCS, fromB64, toB64 } from "@mysten/bcs";
import { SIGNATURE_SCHEME_TO_FLAG } from "@mysten/sui.js/cryptography";
import { bcs } from "@mysten/sui.js/bcs";

@@ -27,5 +28,24 @@ const zkBcs = new BCS(bcs);

});
function getZkSignatureBytes({ inputs, maxEpoch, userSignature }) {
return zkBcs.ser(
"ZkSignature",
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === "string" ? fromB64(userSignature) : userSignature
},
{ maxSize: 2048 }
).toBytes();
}
function getZkSignature({ inputs, maxEpoch, userSignature }) {
const bytes = getZkSignatureBytes({ inputs, maxEpoch, userSignature });
const signatureBytes = new Uint8Array(bytes.length + 1);
signatureBytes.set([SIGNATURE_SCHEME_TO_FLAG["Zk"]]);
signatureBytes.set(bytes, 1);
return toB64(signatureBytes);
}
export {
getZkSignature,
zkBcs
};
//# sourceMappingURL=bcs.js.map
export { computeZkAddress, jwtToAddress } from './address.js';
export type { ComputeZKAddressOptions } from './address.js';
export { zkBcs } from './bcs.js';
export { getZkSignature } from './bcs.js';
export { poseidonHash } from './poseidon.js';
export { generateNonce } from './nonce.js';
export { convertBase, hashToField, hashASCIIStrToField, genAddressSeed } from './utils.js';
import { computeZkAddress, jwtToAddress } from "./address.js";
import { zkBcs } from "./bcs.js";
import { getZkSignature } from "./bcs.js";
import { poseidonHash } from "./poseidon.js";

@@ -11,8 +11,8 @@ import { generateNonce } from "./nonce.js";

generateNonce,
getZkSignature,
hashASCIIStrToField,
hashToField,
jwtToAddress,
poseidonHash,
zkBcs
poseidonHash
};
//# sourceMappingURL=index.js.map
{
"name": "@mysten/zklogin",
"version": "0.0.0-experimental-20230829185142",
"version": "0.0.0-experimental-20230906174457",
"description": "Utilities for interacting with zkLogin in Sui",

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

"@mysten/bcs": "0.7.3",
"@mysten/sui.js": "0.0.0-experimental-20230829185142"
"@mysten/sui.js": "0.41.1"
},

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

@@ -14,9 +14,3 @@ // Copyright (c) Mysten Labs, Inc.

const decodedJWT = decodeJwt(jwt);
if (
!decodedJWT.sub ||
!decodedJWT.iss ||
!decodedJWT.aud ||
!decodedJWT.email ||
typeof decodedJWT.email !== 'string'
) {
if (!decodedJWT.sub || !decodedJWT.iss || !decodedJWT.aud) {
throw new Error('Missing jwt data');

@@ -23,0 +17,0 @@ }

// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { BCS } from '@mysten/bcs';
import { BCS, fromB64, toB64 } from '@mysten/bcs';
import { SIGNATURE_SCHEME_TO_FLAG } from '@mysten/sui.js/cryptography';
import { bcs } from '@mysten/sui.js/bcs';

@@ -20,2 +21,27 @@

type Claim = {
name: string;
value_base64: string;
index_mod_4: 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;
}
export interface ZkSignature {
inputs: ZkSignatureInputs;
maxEpoch: number;
userSignature: string | Uint8Array;
}
zkBcs.registerStructType('ZkSignature', {

@@ -35,1 +61,23 @@ inputs: {

});
function getZkSignatureBytes({ inputs, maxEpoch, userSignature }: ZkSignature) {
return zkBcs
.ser(
'ZkSignature',
{
inputs,
max_epoch: maxEpoch,
user_signature: typeof userSignature === 'string' ? fromB64(userSignature) : userSignature,
},
{ maxSize: 2048 },
)
.toBytes();
}
export function getZkSignature({ inputs, maxEpoch, userSignature }: ZkSignature) {
const bytes = getZkSignatureBytes({ inputs, maxEpoch, userSignature });
const signatureBytes = new Uint8Array(bytes.length + 1);
signatureBytes.set([SIGNATURE_SCHEME_TO_FLAG['Zk']]);
signatureBytes.set(bytes, 1);
return toB64(signatureBytes);
}

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

export { zkBcs } from './bcs.js';
export { getZkSignature } from './bcs.js';

@@ -10,0 +10,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