@sip-protocol/sdk 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4053,17 +4053,33 @@ function validateStealthMetaAddress(metaAddress, field = "recipientMetaAddress")
4053
4053
  `${field}.chain`
4054
4054
  );
4055
4055
  }
4056
- if (!isValidCompressedPublicKey(metaAddress.spendingKey)) {
4057
- throw new ValidationError(
4058
- "spendingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)",
4059
- `${field}.spendingKey`
4060
- );
4061
- }
4062
- if (!isValidCompressedPublicKey(metaAddress.viewingKey)) {
4063
- throw new ValidationError(
4064
- "viewingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)",
4065
- `${field}.viewingKey`
4066
- );
4056
+ const isEd25519 = isEd25519Chain(metaAddress.chain);
4057
+ if (isEd25519) {
4058
+ if (!isValidEd25519PublicKey(metaAddress.spendingKey)) {
4059
+ throw new ValidationError(
4060
+ "spendingKey must be a valid ed25519 public key (32 bytes)",
4061
+ `${field}.spendingKey`
4062
+ );
4063
+ }
4064
+ if (!isValidEd25519PublicKey(metaAddress.viewingKey)) {
4065
+ throw new ValidationError(
4066
+ "viewingKey must be a valid ed25519 public key (32 bytes)",
4067
+ `${field}.viewingKey`
4068
+ );
4069
+ }
4070
+ } else {
4071
+ if (!isValidCompressedPublicKey(metaAddress.spendingKey)) {
4072
+ throw new ValidationError(
4073
+ "spendingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)",
4074
+ `${field}.spendingKey`
4075
+ );
4076
+ }
4077
+ if (!isValidCompressedPublicKey(metaAddress.viewingKey)) {
4078
+ throw new ValidationError(
4079
+ "viewingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)",
4080
+ `${field}.viewingKey`
4081
+ );
4082
+ }
4067
4083
  }
4068
4084
  }
4069
4085
  function generateStealthAddress(recipientMetaAddress) {
package/dist/index.mjs CHANGED
@@ -253,7 +253,7 @@ import {
253
253
  walletRegistry,
254
254
  withSecureBuffer,
255
255
  withSecureBufferSync
256
- } from "./chunk-PCFM7FQO.mjs";
256
+ } from "./chunk-GOOEOAMV.mjs";
257
257
  import {
258
258
  CryptoError,
259
259
  EncryptionNotImplementedError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sip-protocol/sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Core SDK for Shielded Intents Protocol - Privacy layer for cross-chain transactions",
5
5
  "author": "SIP Protocol <hello@sip-protocol.org>",
6
6
  "homepage": "https://sip-protocol.org",
package/src/stealth.ts CHANGED
@@ -144,6 +144,7 @@ export function generateStealthMetaAddress(
144
144
 
145
145
  /**
146
146
  * Validate a StealthMetaAddress object
147
+ * Supports both secp256k1 (EVM chains) and ed25519 (Solana, NEAR, etc.) key formats
147
148
  */
148
149
  function validateStealthMetaAddress(
149
150
  metaAddress: StealthMetaAddress,
@@ -161,20 +162,37 @@ function validateStealthMetaAddress(
161
162
  )
162
163
  }
163
164
 
164
- // Validate spending key
165
- if (!isValidCompressedPublicKey(metaAddress.spendingKey)) {
166
- throw new ValidationError(
167
- 'spendingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)',
168
- `${field}.spendingKey`
169
- )
170
- }
165
+ // Determine key type based on chain (ed25519 vs secp256k1)
166
+ const isEd25519 = isEd25519Chain(metaAddress.chain)
171
167
 
172
- // Validate viewing key
173
- if (!isValidCompressedPublicKey(metaAddress.viewingKey)) {
174
- throw new ValidationError(
175
- 'viewingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)',
176
- `${field}.viewingKey`
177
- )
168
+ if (isEd25519) {
169
+ // Ed25519 chains (Solana, NEAR, Aptos, Sui) use 32-byte public keys
170
+ if (!isValidEd25519PublicKey(metaAddress.spendingKey)) {
171
+ throw new ValidationError(
172
+ 'spendingKey must be a valid ed25519 public key (32 bytes)',
173
+ `${field}.spendingKey`
174
+ )
175
+ }
176
+ if (!isValidEd25519PublicKey(metaAddress.viewingKey)) {
177
+ throw new ValidationError(
178
+ 'viewingKey must be a valid ed25519 public key (32 bytes)',
179
+ `${field}.viewingKey`
180
+ )
181
+ }
182
+ } else {
183
+ // Secp256k1 chains (Ethereum, etc.) use 33-byte compressed public keys
184
+ if (!isValidCompressedPublicKey(metaAddress.spendingKey)) {
185
+ throw new ValidationError(
186
+ 'spendingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)',
187
+ `${field}.spendingKey`
188
+ )
189
+ }
190
+ if (!isValidCompressedPublicKey(metaAddress.viewingKey)) {
191
+ throw new ValidationError(
192
+ 'viewingKey must be a valid compressed secp256k1 public key (33 bytes, starting with 02 or 03)',
193
+ `${field}.viewingKey`
194
+ )
195
+ }
178
196
  }
179
197
  }
180
198