diff --git a/bun.lock b/bun.lock index 506d1e33ae..71833d34d8 100644 --- a/bun.lock +++ b/bun.lock @@ -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", @@ -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", @@ -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", diff --git a/e2e/src/e2e.spec.ts b/e2e/src/e2e.spec.ts index 66ef13c71b..f7c350b530 100644 --- a/e2e/src/e2e.spec.ts +++ b/e2e/src/e2e.spec.ts @@ -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', () => @@ -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', () => diff --git a/e2e/src/init.ts b/e2e/src/init.ts index 190b7b1211..9d29e8694c 100644 --- a/e2e/src/init.ts +++ b/e2e/src/init.ts @@ -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 @@ -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 @@ -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, diff --git a/package.json b/package.json index e3dd9279da..3c9a9f0f88 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/auth-services/package.json b/packages/auth-services/package.json index 80dd770e71..b4ba6eb10c 100644 --- a/packages/auth-services/package.json +++ b/packages/auth-services/package.json @@ -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", diff --git a/packages/networks/package.json b/packages/networks/package.json index b3fe6dea47..e5b0bd8c2a 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -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", diff --git a/packages/networks/src/networks/vNaga/envs/naga-staging/naga-staging.module.ts b/packages/networks/src/networks/vNaga/envs/naga-staging/naga-staging.module.ts index 21691df038..b6d214f080 100644 --- a/packages/networks/src/networks/vNaga/envs/naga-staging/naga-staging.module.ts +++ b/packages/networks/src/networks/vNaga/envs/naga-staging/naga-staging.module.ts @@ -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), }); diff --git a/packages/networks/src/networks/vNaga/shared/factories/BaseModuleFactory.ts b/packages/networks/src/networks/vNaga/shared/factories/BaseModuleFactory.ts index 8f849c4548..6f979713fe 100644 --- a/packages/networks/src/networks/vNaga/shared/factories/BaseModuleFactory.ts +++ b/packages/networks/src/networks/vNaga/shared/factories/BaseModuleFactory.ts @@ -905,6 +905,14 @@ export function createBaseModule(config: BaseModuleConfig) { jitContext: NagaJitContext, requestId?: string ) => { + if (!result.success) { + E2EERequestManager.handleEncryptedError( + result, + jitContext, + 'Sign Custom Session Key' + ); + } + const decryptedValues = E2EERequestManager.decryptBatchResponse( result, jitContext, diff --git a/packages/wasm/rust/src/sev_snp.rs b/packages/wasm/rust/src/sev_snp.rs index 71588d86fb..a1ac6526bf 100644 --- a/packages/wasm/rust/src/sev_snp.rs +++ b/packages/wasm/rust/src/sev_snp.rs @@ -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 => {