Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "@lit-protocol/js-sdk",
"dependencies": {
"@dotenvx/dotenvx": "^1.6.4",
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "0.5.1",
"@lit-protocol/nacl": "7.1.1",
"@lit-protocol/uint8arrays": "7.1.1",
"@metamask/eth-sig-util": "5.0.2",
Expand Down Expand Up @@ -151,7 +151,7 @@
"@elysiajs/cors": "^1.2.0",
"@elysiajs/static": "^1.3.0",
"@elysiajs/swagger": "^1.2.0",
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "^0.5.1",
"@simplewebauthn/server": "6.2.1",
"@simplewebauthn/typescript-types": "^8.3.4",
"@t3-oss/env-core": "^0.12.0",
Expand Down Expand Up @@ -222,7 +222,7 @@
"name": "@lit-protocol/networks",
"version": "8.0.0-beta.1",
"dependencies": {
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "^0.5.1",
"@lit-protocol/nacl": "7.1.1",
"@noble/curves": "^1.8.1",
"@wagmi/core": "^2.17.1",
Expand Down
13 changes: 3 additions & 10 deletions e2e/src/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ describe('all', () => {
createExecuteJsTest(ctx, () => ctx.aliceEoaAuthContext)());
it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(
ctx,
ctx.aliceViemAccountAuthData
)());
createViewPKPsByAuthDataTest(ctx, ctx.aliceViemAccountAuthData)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => ctx.aliceEoaAuthContext)());
it('encryptDecryptFlow', () =>
Expand Down Expand Up @@ -99,13 +96,9 @@ describe('all', () => {
createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx)());
it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(
ctx,
ctx.aliceViemAccountAuthData
)());
createViewPKPsByAuthDataTest(ctx, ctx.aliceViemAccountAuthData)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
it('encryptDecryptFlow', () =>
Expand Down
47 changes: 20 additions & 27 deletions e2e/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ export const init = async (
});
console.log('✅ Master Payment Balance:', masterPaymentBalance);

async function masterDepositForUser(userAddress: string) {
await masterPaymentManager.depositForUser({
userAddress: userAddress,
amountInEth: LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT,
});
console.log(
`✅ New ${userAddress} Ledger Balance:`,
await masterPaymentManager.getBalance({ userAddress: userAddress })
);
}

/**
* ====================================
* Initialise the AuthManager
Expand Down Expand Up @@ -237,6 +248,14 @@ export const init = async (

const eveViemAccountPkp = pkpData.data;

// Making sure all signers have sufficient ledger balance before calling the signSessionKey endpoint
await masterDepositForUser(aliceViemAccount.address);
await masterDepositForUser(bobViemAccount.address);
await masterDepositForUser(aliceViemAccountPkp.ethAddress);
await masterDepositForUser(bobViemAccountPkp.ethAddress);
await masterDepositForUser(eveViemAccount.address);
await masterDepositForUser(eveViemAccountPkp.ethAddress);

/**
* ====================================
* Create the auth context
Expand Down Expand Up @@ -299,35 +318,9 @@ export const init = async (
* ====================================
*/

async function masterDepositForUser(userAddress: string) {
await masterPaymentManager.depositForUser({
userAddress: userAddress,
amountInEth: LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT,
});
console.log(
`✅ New ${userAddress} Ledger Balance:`,
await masterPaymentManager.getBalance({ userAddress: userAddress })
);
}

// Deposit to the Alice EOA Ledger
await masterDepositForUser(aliceViemAccount.address);

// Deposit to the PKP Ledger
// Deposit to the PKP Viem account Ledger
await masterDepositForUser(alicePkpViemAccount.address);

// Deposit to the Bob EOA Ledger
await masterDepositForUser(bobViemAccount.address);

// Deposit to the Bob PKP Ledger
await masterDepositForUser(bobViemAccountPkp.ethAddress);

// Deposit to the Eve EOA Ledger
await masterDepositForUser(eveViemAccount.address);

// Deposit to the Eve PKP Ledger
await masterDepositForUser(eveViemAccountPkp.ethAddress);

// const alicePkpViemAccountPermissionsManager = await litClient.getPKPPermissionsManager({
// pkpIdentifier: {
// tokenId: aliceViemAccountPkp.tokenId,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"private": true,
"dependencies": {
"@dotenvx/dotenvx": "^1.6.4",
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "0.5.1",
"@lit-protocol/nacl": "7.1.1",
"@lit-protocol/uint8arrays": "7.1.1",
"@metamask/eth-sig-util": "5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@elysiajs/cors": "^1.2.0",
"@elysiajs/static": "^1.3.0",
"@elysiajs/swagger": "^1.2.0",
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "^0.5.1",
"@simplewebauthn/server": "6.2.1",
"@simplewebauthn/typescript-types": "^8.3.4",
"@t3-oss/env-core": "^0.12.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/networks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"directory": "../../dist/packages/networks"
},
"dependencies": {
"@lit-protocol/contracts": "^0.5.0",
"@lit-protocol/contracts": "^0.5.1",
"@lit-protocol/nacl": "7.1.1",
"@noble/curves": "^1.8.1",
"@wagmi/core": "^2.17.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ExpectedAccountOrWalletClient } from '../../shared/managers/contra

const nagaStaging = createBaseModule({
networkConfig: nagaStagingEnvironment.getConfig(),
moduleName: 'naga-staging',
moduleName: nagaStagingEnvironment.getNetworkName(),
createChainManager: (account: ExpectedAccountOrWalletClient) =>
createChainManager(account),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,14 @@ export function createBaseModule<T, M>(config: BaseModuleConfig<T, M>) {
jitContext: NagaJitContext,
requestId?: string
) => {
if (!result.success) {
E2EERequestManager.handleEncryptedError(
result,
jitContext,
'Sign Custom Session Key'
);
}

const decryptedValues = E2EERequestManager.decryptBatchResponse(
result,
jitContext,
Expand Down
8 changes: 7 additions & 1 deletion packages/wasm/rust/src/sev_snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,27 @@ fn get_expected_report_data(
) -> JsResult<[u8; 64]> {
let mut hasher = Sha512::new();
hasher.update("noonce");
hasher.update(&(challenge.len() as u64).to_be_bytes());
hasher.update(challenge);

hasher.update("data");
hasher.update(&(data.len() as u64).to_be_bytes());
for (key, value) in data {
hasher.update(&(key.len() as u64).to_be_bytes());
hasher.update(key);
hasher.update(&(value.len() as u64).to_be_bytes());
hasher.update(value);
}

if !signatures.is_empty() {
hasher.update("signatures");
hasher.update(&(signatures.len() as u64).to_be_bytes());

for idx in 0..((signatures.len() - 1) as usize) {
for idx in 0..=((signatures.len() - 1) as usize) {
let sig = signatures.get(idx);
match sig {
Some(s) => {
hasher.update(&(s.len() as u64).to_be_bytes());
hasher.update(s.clone());
}
None => {
Expand Down
Loading