@medialane/sdk 0.113.0 → 0.114.0
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/starknet/index.cjs
CHANGED
|
@@ -11912,6 +11912,25 @@ async function deriveAesKey(prfSecret, hkdfInfo) {
|
|
|
11912
11912
|
["encrypt", "decrypt"]
|
|
11913
11913
|
);
|
|
11914
11914
|
}
|
|
11915
|
+
var STARK_KEY_INFO = new TextEncoder().encode("medialane/passkey/stark-key/v1");
|
|
11916
|
+
var DERIVE_BITS = 384;
|
|
11917
|
+
function bytesToBigInt(bytes) {
|
|
11918
|
+
let value = 0n;
|
|
11919
|
+
for (const byte of bytes) value = value << 8n | BigInt(byte);
|
|
11920
|
+
return value;
|
|
11921
|
+
}
|
|
11922
|
+
async function deriveStarkKeyPair(prfSecret) {
|
|
11923
|
+
const hkdf = await crypto.subtle.importKey("raw", prfSecret, "HKDF", false, ["deriveBits"]);
|
|
11924
|
+
const bits = await crypto.subtle.deriveBits(
|
|
11925
|
+
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(0), info: STARK_KEY_INFO },
|
|
11926
|
+
hkdf,
|
|
11927
|
+
DERIVE_BITS
|
|
11928
|
+
);
|
|
11929
|
+
const order = starknet.ec.starkCurve.CURVE.n;
|
|
11930
|
+
const value = bytesToBigInt(new Uint8Array(bits)) % (order - 1n) + 1n;
|
|
11931
|
+
const privateKeyHex = "0x" + value.toString(16).padStart(64, "0");
|
|
11932
|
+
return { privateKeyHex, publicKeyHex: starknet.ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
11933
|
+
}
|
|
11915
11934
|
function generateStarkKeyPair() {
|
|
11916
11935
|
const privateKeyHex = "0x" + Array.from(starknet.ec.starkCurve.utils.randomPrivateKey()).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
11917
11936
|
return { privateKeyHex, publicKeyHex: starknet.ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
@@ -12016,6 +12035,7 @@ exports.decodeEscapeAndStatus = decodeEscapeAndStatus;
|
|
|
12016
12035
|
exports.decodeGuardiansInfo = decodeGuardiansInfo;
|
|
12017
12036
|
exports.deriveAesKey = deriveAesKey;
|
|
12018
12037
|
exports.deriveOwnerKeyPair = deriveOwnerKeyPair;
|
|
12038
|
+
exports.deriveStarkKeyPair = deriveStarkKeyPair;
|
|
12019
12039
|
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
12020
12040
|
exports.encodeByteArray = encodeByteArray;
|
|
12021
12041
|
exports.executeIntent = executeIntent;
|