@meshsdk/core-cst 1.6.3 → 1.6.4
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.cjs +153 -141
- package/dist/index.d.cts +52 -42
- package/dist/index.d.ts +52 -42
- package/dist/index.js +141 -131
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -901,7 +901,7 @@ __export(src_exports, {
|
|
|
901
901
|
AssetId: () => AssetId,
|
|
902
902
|
AssetName: () => AssetName,
|
|
903
903
|
BaseAddress: () => BaseAddress,
|
|
904
|
-
Bip32PrivateKey: () =>
|
|
904
|
+
Bip32PrivateKey: () => Bip32PrivateKey2,
|
|
905
905
|
Bip32PrivateKeyHex: () => Bip32PrivateKeyHex2,
|
|
906
906
|
Cardano: () => import_core7.Cardano,
|
|
907
907
|
CardanoSDK: () => CardanoSDK,
|
|
@@ -912,6 +912,7 @@ __export(src_exports, {
|
|
|
912
912
|
Certificate: () => Certificate,
|
|
913
913
|
CertificateType: () => CertificateType,
|
|
914
914
|
ConstrPlutusData: () => ConstrPlutusData,
|
|
915
|
+
CoseSign1: () => CoseSign1,
|
|
915
916
|
CostModel: () => CostModel,
|
|
916
917
|
Costmdls: () => Costmdls,
|
|
917
918
|
Credential: () => Credential,
|
|
@@ -965,11 +966,12 @@ __export(src_exports, {
|
|
|
965
966
|
Slot: () => Slot,
|
|
966
967
|
StakeDelegation: () => StakeDelegation,
|
|
967
968
|
StakeRegistration: () => StakeRegistration,
|
|
968
|
-
StricaBip32PrivateKey: () =>
|
|
969
|
+
StricaBip32PrivateKey: () => Bip32PrivateKey3,
|
|
969
970
|
StricaBip32PublicKey: () => Bip32PublicKey,
|
|
970
|
-
|
|
971
|
+
StricaDecoder: () => Decoder,
|
|
972
|
+
StricaEncoder: () => Encoder,
|
|
971
973
|
StricaPrivateKey: () => PrivateKey,
|
|
972
|
-
StricaPublicKey: () =>
|
|
974
|
+
StricaPublicKey: () => PublicKey,
|
|
973
975
|
Transaction: () => Transaction,
|
|
974
976
|
TransactionBody: () => TransactionBody,
|
|
975
977
|
TransactionId: () => TransactionId,
|
|
@@ -1040,14 +1042,118 @@ __export(src_exports, {
|
|
|
1040
1042
|
module.exports = __toCommonJS(src_exports);
|
|
1041
1043
|
var import_core7 = require("@cardano-sdk/core");
|
|
1042
1044
|
|
|
1043
|
-
// src/
|
|
1044
|
-
var
|
|
1045
|
+
// src/types/cardano-sdk.ts
|
|
1046
|
+
var import_core = require("@cardano-sdk/core");
|
|
1047
|
+
var Crypto = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
1048
|
+
var import_util = require("@cardano-sdk/util");
|
|
1049
|
+
var Slot = import_core.Cardano.Slot;
|
|
1050
|
+
var Value = import_core.Serialization.Value;
|
|
1051
|
+
var Transaction = import_core.Serialization.Transaction;
|
|
1052
|
+
var TransactionId = import_core.Cardano.TransactionId;
|
|
1053
|
+
var TransactionBody = import_core.Serialization.TransactionBody;
|
|
1054
|
+
var TransactionWitnessSet = import_core.Serialization.TransactionWitnessSet;
|
|
1055
|
+
var TransactionUnspentOutput = import_core.Serialization.TransactionUnspentOutput;
|
|
1056
|
+
var TransactionInput = import_core.Serialization.TransactionInput;
|
|
1057
|
+
var TransactionOutput = import_core.Serialization.TransactionOutput;
|
|
1058
|
+
var PlutusData = import_core.Serialization.PlutusData;
|
|
1059
|
+
var PlutusList = import_core.Serialization.PlutusList;
|
|
1060
|
+
var PlutusMap = import_core.Serialization.PlutusMap;
|
|
1061
|
+
var Redeemers = import_core.Serialization.Redeemers;
|
|
1062
|
+
var Redeemer = import_core.Serialization.Redeemer;
|
|
1063
|
+
var RedeemerPurpose = import_core.Cardano.RedeemerPurpose;
|
|
1064
|
+
var RedeemerTag = import_core.Serialization.RedeemerTag;
|
|
1065
|
+
var Script = import_core.Serialization.Script;
|
|
1066
|
+
var PolicyId = import_core.Cardano.PolicyId;
|
|
1067
|
+
var AssetName = import_core.Cardano.AssetName;
|
|
1068
|
+
var AssetId = import_core.Cardano.AssetId;
|
|
1069
|
+
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
1070
|
+
var Address = import_core.Cardano.Address;
|
|
1071
|
+
var RewardAddress = import_core.Cardano.RewardAddress;
|
|
1072
|
+
var AddressType = import_core.Cardano.AddressType;
|
|
1073
|
+
var BaseAddress = import_core.Cardano.BaseAddress;
|
|
1074
|
+
var EnterpriseAddress = import_core.Cardano.EnterpriseAddress;
|
|
1075
|
+
var PaymentAddress = import_core.Cardano.PaymentAddress;
|
|
1076
|
+
var AssetFingerprint = import_core.Cardano.AssetFingerprint;
|
|
1077
|
+
var Credential = import_core.Serialization.Credential;
|
|
1078
|
+
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
1079
|
+
var Ed25519PrivateNormalKeyHex = (value) => (0, import_util.typedHex)(value, 64);
|
|
1080
|
+
var Ed25519PrivateExtendedKeyHex = (value) => (0, import_util.typedHex)(value, 128);
|
|
1081
|
+
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
1082
|
+
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
1083
|
+
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
1084
|
+
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
1085
|
+
var CredentialType = import_core.Cardano.CredentialType;
|
|
1086
|
+
var Certificate = import_core.Serialization.Certificate;
|
|
1087
|
+
var PoolId = import_core.Cardano.PoolId;
|
|
1088
|
+
var StakeRegistration = import_core.Serialization.StakeRegistration;
|
|
1089
|
+
var StakeDelegation = import_core.Serialization.StakeDelegation;
|
|
1090
|
+
var CertificateType = import_core.Cardano.CertificateType;
|
|
1091
|
+
var VkeyWitness = import_core.Serialization.VkeyWitness;
|
|
1092
|
+
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
1093
|
+
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
1094
|
+
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
1095
|
+
var Bip32PrivateKey2 = Crypto.Bip32PrivateKey;
|
|
1096
|
+
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
1097
|
+
var PlutusLanguageVersion = import_core.Cardano.PlutusLanguageVersion;
|
|
1098
|
+
var NativeScript = import_core.Serialization.NativeScript;
|
|
1099
|
+
var PlutusV1Script = import_core.Serialization.PlutusV1Script;
|
|
1100
|
+
var PlutusV2Script = import_core.Serialization.PlutusV2Script;
|
|
1101
|
+
var PlutusV3Script = import_core.Serialization.PlutusV3Script;
|
|
1102
|
+
var Costmdls = import_core.Serialization.Costmdls;
|
|
1103
|
+
var CostModel = import_core.Serialization.CostModel;
|
|
1104
|
+
var CborWriter = import_core.Serialization.CborWriter;
|
|
1105
|
+
var ConstrPlutusData = import_core.Serialization.ConstrPlutusData;
|
|
1106
|
+
var RewardAccount = import_core.Cardano.RewardAccount;
|
|
1107
|
+
var Hash = import_core.Serialization.Hash;
|
|
1108
|
+
var DatumHash = Crypto.Hash32ByteBase16;
|
|
1109
|
+
var Datum = import_core.Serialization.Datum;
|
|
1110
|
+
var ExUnits = import_core.Serialization.ExUnits;
|
|
1111
|
+
var NetworkId = import_core.Cardano.NetworkId;
|
|
1112
|
+
var DatumKind = import_core.Serialization.DatumKind;
|
|
1113
|
+
var CborSet = import_core.Serialization.CborSet;
|
|
1114
|
+
var RequireAllOf = import_core.Cardano.NativeScriptKind.RequireAllOf;
|
|
1115
|
+
var RequireAnyOf = import_core.Cardano.NativeScriptKind.RequireAnyOf;
|
|
1116
|
+
var RequireNOf = import_core.Cardano.NativeScriptKind.RequireNOf;
|
|
1117
|
+
var RequireSignature = import_core.Cardano.NativeScriptKind.RequireSignature;
|
|
1118
|
+
var RequireTimeAfter = import_core.Cardano.NativeScriptKind.RequireTimeAfter;
|
|
1119
|
+
var RequireTimeBefore = import_core.Cardano.NativeScriptKind.RequireTimeBefore;
|
|
1120
|
+
var VrfVkBech32 = import_core.Cardano.VrfVkBech32;
|
|
1121
|
+
var ScriptPubkey = import_core.Serialization.ScriptPubkey;
|
|
1122
|
+
var DRepID = import_core.Cardano.DRepID;
|
|
1045
1123
|
|
|
1046
|
-
// src/
|
|
1124
|
+
// src/message-signing/cose-sign1.ts
|
|
1047
1125
|
var import_buffer = require("buffer");
|
|
1048
|
-
var import_bip32ed25519 = require("@stricahq/bip32ed25519");
|
|
1049
|
-
var import_cbors = require("@stricahq/cbors");
|
|
1050
1126
|
var import_blakejs = __toESM(require_blakejs(), 1);
|
|
1127
|
+
|
|
1128
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
1129
|
+
var import_bip32ed255192 = __toESM(require("@stricahq/bip32ed25519"), 1);
|
|
1130
|
+
|
|
1131
|
+
// src/stricahq/bip32ed25519/privateKey.ts
|
|
1132
|
+
var import_bip32ed25519 = __toESM(require("@stricahq/bip32ed25519"), 1);
|
|
1133
|
+
var import_hash = __toESM(require("hash.js"), 1);
|
|
1134
|
+
var PrivateKey = class extends import_bip32ed25519.default.PrivateKey {
|
|
1135
|
+
constructor(privKey, extended = true) {
|
|
1136
|
+
if (!extended) {
|
|
1137
|
+
let extendedSecret = import_hash.default.sha512().update(privKey).digest();
|
|
1138
|
+
if (extendedSecret[0] && extendedSecret[31]) {
|
|
1139
|
+
extendedSecret[0] &= 248;
|
|
1140
|
+
extendedSecret[31] &= 63;
|
|
1141
|
+
extendedSecret[31] |= 64;
|
|
1142
|
+
}
|
|
1143
|
+
privKey = Buffer.from(extendedSecret);
|
|
1144
|
+
}
|
|
1145
|
+
super(privKey);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
1150
|
+
var { PublicKey, Bip32PrivateKey: Bip32PrivateKey3, Bip32PublicKey } = import_bip32ed255192.default;
|
|
1151
|
+
|
|
1152
|
+
// src/stricahq/cbors/index.ts
|
|
1153
|
+
var import_cbors = __toESM(require("@stricahq/cbors"), 1);
|
|
1154
|
+
var { Encoder, Decoder } = import_cbors.default;
|
|
1155
|
+
|
|
1156
|
+
// src/message-signing/cose-sign1.ts
|
|
1051
1157
|
var CoseSign1 = class _CoseSign1 {
|
|
1052
1158
|
protectedMap;
|
|
1053
1159
|
unProtectedMap;
|
|
@@ -1063,13 +1169,13 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1063
1169
|
this.signature = payload.signature;
|
|
1064
1170
|
}
|
|
1065
1171
|
static fromCbor(cbor) {
|
|
1066
|
-
const decoded =
|
|
1172
|
+
const decoded = Decoder.decode(import_buffer.Buffer.from(cbor, "hex"));
|
|
1067
1173
|
if (!(decoded.value instanceof Array)) throw Error("Invalid CBOR");
|
|
1068
1174
|
if (decoded.value.length !== 4) throw Error("Invalid COSE_SIGN1");
|
|
1069
1175
|
let protectedMap;
|
|
1070
1176
|
const protectedSerialized = decoded.value[0];
|
|
1071
1177
|
try {
|
|
1072
|
-
protectedMap =
|
|
1178
|
+
protectedMap = Decoder.decode(protectedSerialized).value;
|
|
1073
1179
|
if (!(protectedMap instanceof Map)) {
|
|
1074
1180
|
throw Error();
|
|
1075
1181
|
}
|
|
@@ -1090,7 +1196,7 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1090
1196
|
createSigStructure(externalAad = import_buffer.Buffer.alloc(0)) {
|
|
1091
1197
|
let protectedSerialized = import_buffer.Buffer.alloc(0);
|
|
1092
1198
|
if (this.protectedMap.size !== 0) {
|
|
1093
|
-
protectedSerialized =
|
|
1199
|
+
protectedSerialized = Encoder.encode(this.protectedMap);
|
|
1094
1200
|
}
|
|
1095
1201
|
const structure = [
|
|
1096
1202
|
"Signature1",
|
|
@@ -1098,13 +1204,13 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1098
1204
|
externalAad,
|
|
1099
1205
|
this.payload
|
|
1100
1206
|
];
|
|
1101
|
-
return
|
|
1207
|
+
return Encoder.encode(structure);
|
|
1102
1208
|
}
|
|
1103
1209
|
buildMessage(signature) {
|
|
1104
1210
|
this.signature = signature;
|
|
1105
1211
|
let protectedSerialized = import_buffer.Buffer.alloc(0);
|
|
1106
1212
|
if (this.protectedMap.size !== 0) {
|
|
1107
|
-
protectedSerialized =
|
|
1213
|
+
protectedSerialized = Encoder.encode(this.protectedMap);
|
|
1108
1214
|
}
|
|
1109
1215
|
const coseSign1 = [
|
|
1110
1216
|
protectedSerialized,
|
|
@@ -1112,7 +1218,7 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1112
1218
|
this.payload,
|
|
1113
1219
|
this.signature
|
|
1114
1220
|
];
|
|
1115
|
-
return
|
|
1221
|
+
return Encoder.encode(coseSign1);
|
|
1116
1222
|
}
|
|
1117
1223
|
verifySignature({
|
|
1118
1224
|
externalAad = import_buffer.Buffer.alloc(0),
|
|
@@ -1123,7 +1229,7 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1123
1229
|
}
|
|
1124
1230
|
if (!publicKeyBuffer) throw Error("Public key not found");
|
|
1125
1231
|
if (!this.signature) throw Error("Signature not found");
|
|
1126
|
-
const publicKey = new
|
|
1232
|
+
const publicKey = new PublicKey(publicKeyBuffer);
|
|
1127
1233
|
return publicKey.verify(
|
|
1128
1234
|
this.signature,
|
|
1129
1235
|
this.createSigStructure(externalAad)
|
|
@@ -1154,7 +1260,7 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1154
1260
|
}
|
|
1155
1261
|
};
|
|
1156
1262
|
var getPublicKeyFromCoseKey = (cbor) => {
|
|
1157
|
-
const decodedCoseKey =
|
|
1263
|
+
const decodedCoseKey = Decoder.decode(import_buffer.Buffer.from(cbor, "hex"));
|
|
1158
1264
|
const publicKeyBuffer = decodedCoseKey.value.get(-2);
|
|
1159
1265
|
if (publicKeyBuffer) {
|
|
1160
1266
|
return publicKeyBuffer;
|
|
@@ -1167,109 +1273,23 @@ var getCoseKeyFromPublicKey = (cbor) => {
|
|
|
1167
1273
|
coseKeyMap.set(3, -8);
|
|
1168
1274
|
coseKeyMap.set(6, -2);
|
|
1169
1275
|
coseKeyMap.set(-2, import_buffer.Buffer.from(cbor, "hex"));
|
|
1170
|
-
return
|
|
1276
|
+
return Encoder.encode(coseKeyMap);
|
|
1171
1277
|
};
|
|
1172
1278
|
|
|
1173
|
-
// src/
|
|
1174
|
-
var
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
extendedSecret[0] &= 248;
|
|
1182
|
-
extendedSecret[31] &= 63;
|
|
1183
|
-
extendedSecret[31] |= 64;
|
|
1184
|
-
}
|
|
1185
|
-
privKey = Buffer.from(extendedSecret);
|
|
1186
|
-
}
|
|
1187
|
-
super(privKey);
|
|
1279
|
+
// src/message-signing/check-signature.ts
|
|
1280
|
+
var checkSignature = (data, { key, signature }) => {
|
|
1281
|
+
const builder = CoseSign1.fromCbor(signature);
|
|
1282
|
+
if (builder.getPayload() === null) {
|
|
1283
|
+
return false;
|
|
1284
|
+
}
|
|
1285
|
+
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1286
|
+
return false;
|
|
1188
1287
|
}
|
|
1288
|
+
return builder.verifySignature({
|
|
1289
|
+
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1290
|
+
});
|
|
1189
1291
|
};
|
|
1190
1292
|
|
|
1191
|
-
// src/stricahq/index.ts
|
|
1192
|
-
var { PublicKey: PublicKey2, Bip32PrivateKey, Bip32PublicKey } = import_bip32ed255193.default;
|
|
1193
|
-
|
|
1194
|
-
// src/types/cardano-sdk.ts
|
|
1195
|
-
var import_core = require("@cardano-sdk/core");
|
|
1196
|
-
var Crypto = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
1197
|
-
var import_util = require("@cardano-sdk/util");
|
|
1198
|
-
var Slot = import_core.Cardano.Slot;
|
|
1199
|
-
var Value = import_core.Serialization.Value;
|
|
1200
|
-
var Transaction = import_core.Serialization.Transaction;
|
|
1201
|
-
var TransactionId = import_core.Cardano.TransactionId;
|
|
1202
|
-
var TransactionBody = import_core.Serialization.TransactionBody;
|
|
1203
|
-
var TransactionWitnessSet = import_core.Serialization.TransactionWitnessSet;
|
|
1204
|
-
var TransactionUnspentOutput = import_core.Serialization.TransactionUnspentOutput;
|
|
1205
|
-
var TransactionInput = import_core.Serialization.TransactionInput;
|
|
1206
|
-
var TransactionOutput = import_core.Serialization.TransactionOutput;
|
|
1207
|
-
var PlutusData = import_core.Serialization.PlutusData;
|
|
1208
|
-
var PlutusList = import_core.Serialization.PlutusList;
|
|
1209
|
-
var PlutusMap = import_core.Serialization.PlutusMap;
|
|
1210
|
-
var Redeemers = import_core.Serialization.Redeemers;
|
|
1211
|
-
var Redeemer = import_core.Serialization.Redeemer;
|
|
1212
|
-
var RedeemerPurpose = import_core.Cardano.RedeemerPurpose;
|
|
1213
|
-
var RedeemerTag = import_core.Serialization.RedeemerTag;
|
|
1214
|
-
var Script = import_core.Serialization.Script;
|
|
1215
|
-
var PolicyId = import_core.Cardano.PolicyId;
|
|
1216
|
-
var AssetName = import_core.Cardano.AssetName;
|
|
1217
|
-
var AssetId = import_core.Cardano.AssetId;
|
|
1218
|
-
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
1219
|
-
var Address = import_core.Cardano.Address;
|
|
1220
|
-
var RewardAddress = import_core.Cardano.RewardAddress;
|
|
1221
|
-
var AddressType = import_core.Cardano.AddressType;
|
|
1222
|
-
var BaseAddress = import_core.Cardano.BaseAddress;
|
|
1223
|
-
var EnterpriseAddress = import_core.Cardano.EnterpriseAddress;
|
|
1224
|
-
var PaymentAddress = import_core.Cardano.PaymentAddress;
|
|
1225
|
-
var AssetFingerprint = import_core.Cardano.AssetFingerprint;
|
|
1226
|
-
var Credential = import_core.Serialization.Credential;
|
|
1227
|
-
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
1228
|
-
var Ed25519PrivateNormalKeyHex = (value) => (0, import_util.typedHex)(value, 64);
|
|
1229
|
-
var Ed25519PrivateExtendedKeyHex = (value) => (0, import_util.typedHex)(value, 128);
|
|
1230
|
-
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
1231
|
-
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
1232
|
-
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
1233
|
-
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
1234
|
-
var CredentialType = import_core.Cardano.CredentialType;
|
|
1235
|
-
var Certificate = import_core.Serialization.Certificate;
|
|
1236
|
-
var PoolId = import_core.Cardano.PoolId;
|
|
1237
|
-
var StakeRegistration = import_core.Serialization.StakeRegistration;
|
|
1238
|
-
var StakeDelegation = import_core.Serialization.StakeDelegation;
|
|
1239
|
-
var CertificateType = import_core.Cardano.CertificateType;
|
|
1240
|
-
var VkeyWitness = import_core.Serialization.VkeyWitness;
|
|
1241
|
-
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
1242
|
-
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
1243
|
-
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
1244
|
-
var Bip32PrivateKey3 = Crypto.Bip32PrivateKey;
|
|
1245
|
-
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
1246
|
-
var PlutusLanguageVersion = import_core.Cardano.PlutusLanguageVersion;
|
|
1247
|
-
var NativeScript = import_core.Serialization.NativeScript;
|
|
1248
|
-
var PlutusV1Script = import_core.Serialization.PlutusV1Script;
|
|
1249
|
-
var PlutusV2Script = import_core.Serialization.PlutusV2Script;
|
|
1250
|
-
var PlutusV3Script = import_core.Serialization.PlutusV3Script;
|
|
1251
|
-
var Costmdls = import_core.Serialization.Costmdls;
|
|
1252
|
-
var CostModel = import_core.Serialization.CostModel;
|
|
1253
|
-
var CborWriter = import_core.Serialization.CborWriter;
|
|
1254
|
-
var ConstrPlutusData = import_core.Serialization.ConstrPlutusData;
|
|
1255
|
-
var RewardAccount = import_core.Cardano.RewardAccount;
|
|
1256
|
-
var Hash = import_core.Serialization.Hash;
|
|
1257
|
-
var DatumHash = Crypto.Hash32ByteBase16;
|
|
1258
|
-
var Datum = import_core.Serialization.Datum;
|
|
1259
|
-
var ExUnits = import_core.Serialization.ExUnits;
|
|
1260
|
-
var NetworkId = import_core.Cardano.NetworkId;
|
|
1261
|
-
var DatumKind = import_core.Serialization.DatumKind;
|
|
1262
|
-
var CborSet = import_core.Serialization.CborSet;
|
|
1263
|
-
var RequireAllOf = import_core.Cardano.NativeScriptKind.RequireAllOf;
|
|
1264
|
-
var RequireAnyOf = import_core.Cardano.NativeScriptKind.RequireAnyOf;
|
|
1265
|
-
var RequireNOf = import_core.Cardano.NativeScriptKind.RequireNOf;
|
|
1266
|
-
var RequireSignature = import_core.Cardano.NativeScriptKind.RequireSignature;
|
|
1267
|
-
var RequireTimeAfter = import_core.Cardano.NativeScriptKind.RequireTimeAfter;
|
|
1268
|
-
var RequireTimeBefore = import_core.Cardano.NativeScriptKind.RequireTimeBefore;
|
|
1269
|
-
var VrfVkBech32 = import_core.Cardano.VrfVkBech32;
|
|
1270
|
-
var ScriptPubkey = import_core.Serialization.ScriptPubkey;
|
|
1271
|
-
var DRepID = import_core.Cardano.DRepID;
|
|
1272
|
-
|
|
1273
1293
|
// ../../node_modules/nanoid/index.js
|
|
1274
1294
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
1275
1295
|
var POOL_SIZE_MULTIPLIER = 128;
|
|
@@ -1307,8 +1327,20 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
|
1307
1327
|
};
|
|
1308
1328
|
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
1309
1329
|
|
|
1310
|
-
// src/message-signing/
|
|
1330
|
+
// src/message-signing/generate-nonce.ts
|
|
1311
1331
|
var import_common = require("@meshsdk/common");
|
|
1332
|
+
var generateNonce = (label = "", length = 32) => {
|
|
1333
|
+
if (length <= 0 || length > 2048) {
|
|
1334
|
+
throw new Error("Length must be bewteen 1 and 2048");
|
|
1335
|
+
}
|
|
1336
|
+
const randomString = customAlphabet(
|
|
1337
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1338
|
+
);
|
|
1339
|
+
const payload = randomString(length);
|
|
1340
|
+
return (0, import_common.stringToHex)(`${label}${payload}`);
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
// src/message-signing/sign-data.ts
|
|
1312
1344
|
var signData = (data, signer) => {
|
|
1313
1345
|
const payload = Buffer.from(data, "hex");
|
|
1314
1346
|
const publicKey = signer.key.toPublicKey().toBytes();
|
|
@@ -1328,28 +1360,6 @@ var signData = (data, signer) => {
|
|
|
1328
1360
|
signature: coseSignature
|
|
1329
1361
|
};
|
|
1330
1362
|
};
|
|
1331
|
-
var checkSignature = (data, { key, signature }) => {
|
|
1332
|
-
const builder = CoseSign1.fromCbor(signature);
|
|
1333
|
-
if (builder.getPayload() === null) {
|
|
1334
|
-
return false;
|
|
1335
|
-
}
|
|
1336
|
-
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1337
|
-
return false;
|
|
1338
|
-
}
|
|
1339
|
-
return builder.verifySignature({
|
|
1340
|
-
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1341
|
-
});
|
|
1342
|
-
};
|
|
1343
|
-
var generateNonce = (label = "", length = 32) => {
|
|
1344
|
-
if (length <= 0 || length > 2048) {
|
|
1345
|
-
throw new Error("Length must be bewteen 1 and 2048");
|
|
1346
|
-
}
|
|
1347
|
-
const randomString = customAlphabet(
|
|
1348
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1349
|
-
);
|
|
1350
|
-
const payload = randomString(length);
|
|
1351
|
-
return (0, import_common.stringToHex)(`${label}${payload}`);
|
|
1352
|
-
};
|
|
1353
1363
|
|
|
1354
1364
|
// src/resolvers/index.ts
|
|
1355
1365
|
var import_core4 = require("@cardano-sdk/core");
|
|
@@ -1402,7 +1412,7 @@ var buildBip32PrivateKey = (entropy, password = "") => {
|
|
|
1402
1412
|
PBKDF2_KEY_SIZE,
|
|
1403
1413
|
PBKDF2_DIGEST_ALGORITHM
|
|
1404
1414
|
);
|
|
1405
|
-
return
|
|
1415
|
+
return Bip32PrivateKey2.fromBytes(clampScalar(xprv));
|
|
1406
1416
|
};
|
|
1407
1417
|
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
1408
1418
|
const cred = {
|
|
@@ -1413,7 +1423,7 @@ var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
|
1413
1423
|
};
|
|
1414
1424
|
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
1415
1425
|
if (typeof entropy === "string") {
|
|
1416
|
-
const rootKey = new
|
|
1426
|
+
const rootKey = new Bip32PrivateKey3(Buffer.from(entropy, "hex"));
|
|
1417
1427
|
const accountKey = rootKey.derive(import_common2.HARDENED_KEY_START + 1852).derive(import_common2.HARDENED_KEY_START + 1815).derive(import_common2.HARDENED_KEY_START + accountIndex);
|
|
1418
1428
|
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
1419
1429
|
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
@@ -2700,6 +2710,7 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
|
2700
2710
|
Certificate,
|
|
2701
2711
|
CertificateType,
|
|
2702
2712
|
ConstrPlutusData,
|
|
2713
|
+
CoseSign1,
|
|
2703
2714
|
CostModel,
|
|
2704
2715
|
Costmdls,
|
|
2705
2716
|
Credential,
|
|
@@ -2755,7 +2766,8 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
|
2755
2766
|
StakeRegistration,
|
|
2756
2767
|
StricaBip32PrivateKey,
|
|
2757
2768
|
StricaBip32PublicKey,
|
|
2758
|
-
|
|
2769
|
+
StricaDecoder,
|
|
2770
|
+
StricaEncoder,
|
|
2759
2771
|
StricaPrivateKey,
|
|
2760
2772
|
StricaPublicKey,
|
|
2761
2773
|
Transaction,
|
package/dist/index.d.cts
CHANGED
|
@@ -2,50 +2,16 @@ import * as _cardano_sdk_core from '@cardano-sdk/core';
|
|
|
2
2
|
import { Cardano, Serialization } from '@cardano-sdk/core';
|
|
3
3
|
export { _cardano_sdk_core as CardanoSDK };
|
|
4
4
|
export { Cardano, Serialization } from '@cardano-sdk/core';
|
|
5
|
-
import strica from '@stricahq/bip32ed25519';
|
|
6
5
|
import * as _cardano_sdk_util from '@cardano-sdk/util';
|
|
7
6
|
import { OpaqueString } from '@cardano-sdk/util';
|
|
8
7
|
export { _cardano_sdk_util as CardanoSDKUtil };
|
|
9
8
|
import * as Crypto from '@cardano-sdk/crypto';
|
|
10
9
|
export { Crypto };
|
|
10
|
+
import strica from '@stricahq/bip32ed25519';
|
|
11
11
|
import { DataSignature, Data, NativeScript as NativeScript$1, PlutusScript, IMeshTxSerializer, DeserializedAddress, BuilderData, IDeserializer, IResolver, MeshTxBuilderBody, Protocol, UTxO, Asset, LanguageVersion } from '@meshsdk/common';
|
|
12
|
-
import * as _cardano_sdk_core_dist_cjs_Cardano from '@cardano-sdk/core/dist/cjs/Cardano';
|
|
13
12
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private protectedMap;
|
|
17
|
-
private unProtectedMap;
|
|
18
|
-
private payload;
|
|
19
|
-
private signature;
|
|
20
|
-
constructor(payload: {
|
|
21
|
-
protectedMap: Map<any, any>;
|
|
22
|
-
unProtectedMap: Map<any, any>;
|
|
23
|
-
payload: Buffer$1 | null;
|
|
24
|
-
signature?: Buffer$1;
|
|
25
|
-
});
|
|
26
|
-
static fromCbor(cbor: string): CoseSign1;
|
|
27
|
-
createSigStructure(externalAad?: Buffer$1): Buffer$1;
|
|
28
|
-
buildMessage(signature: Buffer$1): Buffer$1;
|
|
29
|
-
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
30
|
-
externalAad?: Buffer$1;
|
|
31
|
-
publicKeyBuffer?: Buffer$1;
|
|
32
|
-
}): boolean;
|
|
33
|
-
hashPayload(): void;
|
|
34
|
-
getAddress(): Buffer$1;
|
|
35
|
-
getPublicKey(): Buffer$1;
|
|
36
|
-
getSignature(): Buffer$1 | undefined;
|
|
37
|
-
getPayload(): Buffer$1 | null;
|
|
38
|
-
}
|
|
39
|
-
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer$1;
|
|
40
|
-
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer$1;
|
|
41
|
-
|
|
42
|
-
declare class PrivateKey extends strica.PrivateKey {
|
|
43
|
-
constructor(privKey: Buffer, extended?: Boolean);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare const PublicKey: typeof strica.PublicKey;
|
|
47
|
-
declare const Bip32PrivateKey$1: typeof strica.Bip32PrivateKey;
|
|
48
|
-
declare const Bip32PublicKey: typeof strica.Bip32PublicKey;
|
|
13
|
+
import strica$1 from '@stricahq/cbors';
|
|
14
|
+
import * as _cardano_sdk_core_dist_cjs_Cardano from '@cardano-sdk/core/dist/cjs/Cardano';
|
|
49
15
|
|
|
50
16
|
declare const Slot: (value: number) => Cardano.Slot;
|
|
51
17
|
type Slot = Cardano.Slot;
|
|
@@ -173,8 +139,8 @@ declare const Ed25519PublicKey: typeof Crypto.Ed25519PublicKey;
|
|
|
173
139
|
type Ed25519PublicKey = Crypto.Ed25519PublicKey;
|
|
174
140
|
declare const Ed25519Signature: typeof Crypto.Ed25519Signature;
|
|
175
141
|
type Ed25519Signature = Crypto.Ed25519Signature;
|
|
176
|
-
declare const Bip32PrivateKey: typeof Crypto.Bip32PrivateKey;
|
|
177
|
-
type Bip32PrivateKey = Crypto.Bip32PrivateKey;
|
|
142
|
+
declare const Bip32PrivateKey$1: typeof Crypto.Bip32PrivateKey;
|
|
143
|
+
type Bip32PrivateKey$1 = Crypto.Bip32PrivateKey;
|
|
178
144
|
declare const Bip32PrivateKeyHex: (key: string) => Crypto.Bip32PrivateKeyHex;
|
|
179
145
|
type Bip32PrivateKeyHex = Crypto.Bip32PrivateKeyHex;
|
|
180
146
|
declare const PlutusLanguageVersion: typeof Cardano.PlutusLanguageVersion;
|
|
@@ -251,10 +217,39 @@ type Signer = {
|
|
|
251
217
|
key: PrivateKey;
|
|
252
218
|
};
|
|
253
219
|
|
|
254
|
-
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
255
220
|
declare const checkSignature: (data: string, { key, signature }: DataSignature) => boolean;
|
|
221
|
+
|
|
222
|
+
declare class CoseSign1 {
|
|
223
|
+
private protectedMap;
|
|
224
|
+
private unProtectedMap;
|
|
225
|
+
private payload;
|
|
226
|
+
private signature;
|
|
227
|
+
constructor(payload: {
|
|
228
|
+
protectedMap: Map<any, any>;
|
|
229
|
+
unProtectedMap: Map<any, any>;
|
|
230
|
+
payload: Buffer$1 | null;
|
|
231
|
+
signature?: Buffer$1;
|
|
232
|
+
});
|
|
233
|
+
static fromCbor(cbor: string): CoseSign1;
|
|
234
|
+
createSigStructure(externalAad?: Buffer$1): Buffer$1;
|
|
235
|
+
buildMessage(signature: Buffer$1): Buffer$1;
|
|
236
|
+
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
237
|
+
externalAad?: Buffer$1;
|
|
238
|
+
publicKeyBuffer?: Buffer$1;
|
|
239
|
+
}): boolean;
|
|
240
|
+
hashPayload(): void;
|
|
241
|
+
getAddress(): Buffer$1;
|
|
242
|
+
getPublicKey(): Buffer$1;
|
|
243
|
+
getSignature(): Buffer$1 | undefined;
|
|
244
|
+
getPayload(): Buffer$1 | null;
|
|
245
|
+
}
|
|
246
|
+
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer$1;
|
|
247
|
+
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer$1;
|
|
248
|
+
|
|
256
249
|
declare const generateNonce: (label?: string, length?: number) => string;
|
|
257
250
|
|
|
251
|
+
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
252
|
+
|
|
258
253
|
declare const resolveDataHash: (data: Data) => string;
|
|
259
254
|
declare const resolveNativeScriptAddress: (script: NativeScript$1, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
260
255
|
declare const resolveNativeScriptHash: (script: NativeScript$1) => string;
|
|
@@ -303,9 +298,24 @@ declare class CardanoSDKSerializer implements IMeshTxSerializer {
|
|
|
303
298
|
private createDummyTx;
|
|
304
299
|
}
|
|
305
300
|
|
|
301
|
+
declare class PrivateKey extends strica.PrivateKey {
|
|
302
|
+
constructor(privKey: Buffer, extended?: Boolean);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare const PublicKey: typeof strica.PublicKey;
|
|
306
|
+
declare const Bip32PrivateKey: typeof strica.Bip32PrivateKey;
|
|
307
|
+
declare const Bip32PublicKey: typeof strica.Bip32PublicKey;
|
|
308
|
+
|
|
309
|
+
declare const Encoder: {
|
|
310
|
+
encode: (input: any, options?: {
|
|
311
|
+
collapseBigNumber: Boolean;
|
|
312
|
+
}) => Buffer;
|
|
313
|
+
};
|
|
314
|
+
declare const Decoder: typeof strica$1.Decoder;
|
|
315
|
+
|
|
306
316
|
declare const buildBaseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16, stakeKeyHash: Hash28ByteBase16) => BaseAddress;
|
|
307
317
|
declare const buildEnterpriseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16) => EnterpriseAddress;
|
|
308
|
-
declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey;
|
|
318
|
+
declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey$1;
|
|
309
319
|
declare const buildRewardAddress: (networkId: number, stakeKeyHash: Hash28ByteBase16) => RewardAddress;
|
|
310
320
|
declare const buildKeys: (entropy: string | [string, string], accountIndex: number, keyIndex?: number) => {
|
|
311
321
|
paymentKey: PrivateKey;
|
|
@@ -349,4 +359,4 @@ declare function negatives(v: Value): Value;
|
|
|
349
359
|
declare function assetTypes(v: Value): number;
|
|
350
360
|
declare function empty(v: Value): boolean;
|
|
351
361
|
|
|
352
|
-
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, NativeScript, NetworkId, PaymentAddress, PlutusData, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, Bip32PrivateKey
|
|
362
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey$1 as Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, NativeScript, NetworkId, PaymentAddress, PlutusData, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, Bip32PrivateKey as StricaBip32PrivateKey, Bip32PublicKey as StricaBip32PublicKey, Decoder as StricaDecoder, Encoder as StricaEncoder, PrivateKey as StricaPrivateKey, PublicKey as StricaPublicKey, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, Value, VkeyWitness, VrfVkBech32, type Witness, addressToBech32, assetTypes, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, checkSignature, deserializeAddress, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromNativeScript, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getPublicKeyFromCoseKey, mergeValue, negateValue, negatives, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, signData, subValue, toAddress, toBaseAddress, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,50 +2,16 @@ import * as _cardano_sdk_core from '@cardano-sdk/core';
|
|
|
2
2
|
import { Cardano, Serialization } from '@cardano-sdk/core';
|
|
3
3
|
export { _cardano_sdk_core as CardanoSDK };
|
|
4
4
|
export { Cardano, Serialization } from '@cardano-sdk/core';
|
|
5
|
-
import strica from '@stricahq/bip32ed25519';
|
|
6
5
|
import * as _cardano_sdk_util from '@cardano-sdk/util';
|
|
7
6
|
import { OpaqueString } from '@cardano-sdk/util';
|
|
8
7
|
export { _cardano_sdk_util as CardanoSDKUtil };
|
|
9
8
|
import * as Crypto from '@cardano-sdk/crypto';
|
|
10
9
|
export { Crypto };
|
|
10
|
+
import strica from '@stricahq/bip32ed25519';
|
|
11
11
|
import { DataSignature, Data, NativeScript as NativeScript$1, PlutusScript, IMeshTxSerializer, DeserializedAddress, BuilderData, IDeserializer, IResolver, MeshTxBuilderBody, Protocol, UTxO, Asset, LanguageVersion } from '@meshsdk/common';
|
|
12
|
-
import * as _cardano_sdk_core_dist_cjs_Cardano from '@cardano-sdk/core/dist/cjs/Cardano';
|
|
13
12
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private protectedMap;
|
|
17
|
-
private unProtectedMap;
|
|
18
|
-
private payload;
|
|
19
|
-
private signature;
|
|
20
|
-
constructor(payload: {
|
|
21
|
-
protectedMap: Map<any, any>;
|
|
22
|
-
unProtectedMap: Map<any, any>;
|
|
23
|
-
payload: Buffer$1 | null;
|
|
24
|
-
signature?: Buffer$1;
|
|
25
|
-
});
|
|
26
|
-
static fromCbor(cbor: string): CoseSign1;
|
|
27
|
-
createSigStructure(externalAad?: Buffer$1): Buffer$1;
|
|
28
|
-
buildMessage(signature: Buffer$1): Buffer$1;
|
|
29
|
-
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
30
|
-
externalAad?: Buffer$1;
|
|
31
|
-
publicKeyBuffer?: Buffer$1;
|
|
32
|
-
}): boolean;
|
|
33
|
-
hashPayload(): void;
|
|
34
|
-
getAddress(): Buffer$1;
|
|
35
|
-
getPublicKey(): Buffer$1;
|
|
36
|
-
getSignature(): Buffer$1 | undefined;
|
|
37
|
-
getPayload(): Buffer$1 | null;
|
|
38
|
-
}
|
|
39
|
-
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer$1;
|
|
40
|
-
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer$1;
|
|
41
|
-
|
|
42
|
-
declare class PrivateKey extends strica.PrivateKey {
|
|
43
|
-
constructor(privKey: Buffer, extended?: Boolean);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare const PublicKey: typeof strica.PublicKey;
|
|
47
|
-
declare const Bip32PrivateKey$1: typeof strica.Bip32PrivateKey;
|
|
48
|
-
declare const Bip32PublicKey: typeof strica.Bip32PublicKey;
|
|
13
|
+
import strica$1 from '@stricahq/cbors';
|
|
14
|
+
import * as _cardano_sdk_core_dist_cjs_Cardano from '@cardano-sdk/core/dist/cjs/Cardano';
|
|
49
15
|
|
|
50
16
|
declare const Slot: (value: number) => Cardano.Slot;
|
|
51
17
|
type Slot = Cardano.Slot;
|
|
@@ -173,8 +139,8 @@ declare const Ed25519PublicKey: typeof Crypto.Ed25519PublicKey;
|
|
|
173
139
|
type Ed25519PublicKey = Crypto.Ed25519PublicKey;
|
|
174
140
|
declare const Ed25519Signature: typeof Crypto.Ed25519Signature;
|
|
175
141
|
type Ed25519Signature = Crypto.Ed25519Signature;
|
|
176
|
-
declare const Bip32PrivateKey: typeof Crypto.Bip32PrivateKey;
|
|
177
|
-
type Bip32PrivateKey = Crypto.Bip32PrivateKey;
|
|
142
|
+
declare const Bip32PrivateKey$1: typeof Crypto.Bip32PrivateKey;
|
|
143
|
+
type Bip32PrivateKey$1 = Crypto.Bip32PrivateKey;
|
|
178
144
|
declare const Bip32PrivateKeyHex: (key: string) => Crypto.Bip32PrivateKeyHex;
|
|
179
145
|
type Bip32PrivateKeyHex = Crypto.Bip32PrivateKeyHex;
|
|
180
146
|
declare const PlutusLanguageVersion: typeof Cardano.PlutusLanguageVersion;
|
|
@@ -251,10 +217,39 @@ type Signer = {
|
|
|
251
217
|
key: PrivateKey;
|
|
252
218
|
};
|
|
253
219
|
|
|
254
|
-
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
255
220
|
declare const checkSignature: (data: string, { key, signature }: DataSignature) => boolean;
|
|
221
|
+
|
|
222
|
+
declare class CoseSign1 {
|
|
223
|
+
private protectedMap;
|
|
224
|
+
private unProtectedMap;
|
|
225
|
+
private payload;
|
|
226
|
+
private signature;
|
|
227
|
+
constructor(payload: {
|
|
228
|
+
protectedMap: Map<any, any>;
|
|
229
|
+
unProtectedMap: Map<any, any>;
|
|
230
|
+
payload: Buffer$1 | null;
|
|
231
|
+
signature?: Buffer$1;
|
|
232
|
+
});
|
|
233
|
+
static fromCbor(cbor: string): CoseSign1;
|
|
234
|
+
createSigStructure(externalAad?: Buffer$1): Buffer$1;
|
|
235
|
+
buildMessage(signature: Buffer$1): Buffer$1;
|
|
236
|
+
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
237
|
+
externalAad?: Buffer$1;
|
|
238
|
+
publicKeyBuffer?: Buffer$1;
|
|
239
|
+
}): boolean;
|
|
240
|
+
hashPayload(): void;
|
|
241
|
+
getAddress(): Buffer$1;
|
|
242
|
+
getPublicKey(): Buffer$1;
|
|
243
|
+
getSignature(): Buffer$1 | undefined;
|
|
244
|
+
getPayload(): Buffer$1 | null;
|
|
245
|
+
}
|
|
246
|
+
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer$1;
|
|
247
|
+
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer$1;
|
|
248
|
+
|
|
256
249
|
declare const generateNonce: (label?: string, length?: number) => string;
|
|
257
250
|
|
|
251
|
+
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
252
|
+
|
|
258
253
|
declare const resolveDataHash: (data: Data) => string;
|
|
259
254
|
declare const resolveNativeScriptAddress: (script: NativeScript$1, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
260
255
|
declare const resolveNativeScriptHash: (script: NativeScript$1) => string;
|
|
@@ -303,9 +298,24 @@ declare class CardanoSDKSerializer implements IMeshTxSerializer {
|
|
|
303
298
|
private createDummyTx;
|
|
304
299
|
}
|
|
305
300
|
|
|
301
|
+
declare class PrivateKey extends strica.PrivateKey {
|
|
302
|
+
constructor(privKey: Buffer, extended?: Boolean);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare const PublicKey: typeof strica.PublicKey;
|
|
306
|
+
declare const Bip32PrivateKey: typeof strica.Bip32PrivateKey;
|
|
307
|
+
declare const Bip32PublicKey: typeof strica.Bip32PublicKey;
|
|
308
|
+
|
|
309
|
+
declare const Encoder: {
|
|
310
|
+
encode: (input: any, options?: {
|
|
311
|
+
collapseBigNumber: Boolean;
|
|
312
|
+
}) => Buffer;
|
|
313
|
+
};
|
|
314
|
+
declare const Decoder: typeof strica$1.Decoder;
|
|
315
|
+
|
|
306
316
|
declare const buildBaseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16, stakeKeyHash: Hash28ByteBase16) => BaseAddress;
|
|
307
317
|
declare const buildEnterpriseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16) => EnterpriseAddress;
|
|
308
|
-
declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey;
|
|
318
|
+
declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey$1;
|
|
309
319
|
declare const buildRewardAddress: (networkId: number, stakeKeyHash: Hash28ByteBase16) => RewardAddress;
|
|
310
320
|
declare const buildKeys: (entropy: string | [string, string], accountIndex: number, keyIndex?: number) => {
|
|
311
321
|
paymentKey: PrivateKey;
|
|
@@ -349,4 +359,4 @@ declare function negatives(v: Value): Value;
|
|
|
349
359
|
declare function assetTypes(v: Value): number;
|
|
350
360
|
declare function empty(v: Value): boolean;
|
|
351
361
|
|
|
352
|
-
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, NativeScript, NetworkId, PaymentAddress, PlutusData, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, Bip32PrivateKey
|
|
362
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey$1 as Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, NativeScript, NetworkId, PaymentAddress, PlutusData, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, Bip32PrivateKey as StricaBip32PrivateKey, Bip32PublicKey as StricaBip32PublicKey, Decoder as StricaDecoder, Encoder as StricaEncoder, PrivateKey as StricaPrivateKey, PublicKey as StricaPublicKey, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, Value, VkeyWitness, VrfVkBech32, type Witness, addressToBech32, assetTypes, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, checkSignature, deserializeAddress, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromNativeScript, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getPublicKeyFromCoseKey, mergeValue, negateValue, negatives, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, signData, subValue, toAddress, toBaseAddress, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue };
|
package/dist/index.js
CHANGED
|
@@ -889,14 +889,118 @@ var require_blakejs = __commonJS({
|
|
|
889
889
|
// src/index.ts
|
|
890
890
|
import { Cardano as Cardano4, Serialization as Serialization5 } from "@cardano-sdk/core";
|
|
891
891
|
|
|
892
|
-
// src/
|
|
893
|
-
import
|
|
892
|
+
// src/types/cardano-sdk.ts
|
|
893
|
+
import { Cardano, Serialization } from "@cardano-sdk/core";
|
|
894
|
+
import * as Crypto from "@cardano-sdk/crypto";
|
|
895
|
+
import { typedHex } from "@cardano-sdk/util";
|
|
896
|
+
var Slot = Cardano.Slot;
|
|
897
|
+
var Value = Serialization.Value;
|
|
898
|
+
var Transaction = Serialization.Transaction;
|
|
899
|
+
var TransactionId = Cardano.TransactionId;
|
|
900
|
+
var TransactionBody = Serialization.TransactionBody;
|
|
901
|
+
var TransactionWitnessSet = Serialization.TransactionWitnessSet;
|
|
902
|
+
var TransactionUnspentOutput = Serialization.TransactionUnspentOutput;
|
|
903
|
+
var TransactionInput = Serialization.TransactionInput;
|
|
904
|
+
var TransactionOutput = Serialization.TransactionOutput;
|
|
905
|
+
var PlutusData = Serialization.PlutusData;
|
|
906
|
+
var PlutusList = Serialization.PlutusList;
|
|
907
|
+
var PlutusMap = Serialization.PlutusMap;
|
|
908
|
+
var Redeemers = Serialization.Redeemers;
|
|
909
|
+
var Redeemer = Serialization.Redeemer;
|
|
910
|
+
var RedeemerPurpose = Cardano.RedeemerPurpose;
|
|
911
|
+
var RedeemerTag = Serialization.RedeemerTag;
|
|
912
|
+
var Script = Serialization.Script;
|
|
913
|
+
var PolicyId = Cardano.PolicyId;
|
|
914
|
+
var AssetName = Cardano.AssetName;
|
|
915
|
+
var AssetId = Cardano.AssetId;
|
|
916
|
+
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
917
|
+
var Address = Cardano.Address;
|
|
918
|
+
var RewardAddress = Cardano.RewardAddress;
|
|
919
|
+
var AddressType = Cardano.AddressType;
|
|
920
|
+
var BaseAddress = Cardano.BaseAddress;
|
|
921
|
+
var EnterpriseAddress = Cardano.EnterpriseAddress;
|
|
922
|
+
var PaymentAddress = Cardano.PaymentAddress;
|
|
923
|
+
var AssetFingerprint = Cardano.AssetFingerprint;
|
|
924
|
+
var Credential = Serialization.Credential;
|
|
925
|
+
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
926
|
+
var Ed25519PrivateNormalKeyHex = (value) => typedHex(value, 64);
|
|
927
|
+
var Ed25519PrivateExtendedKeyHex = (value) => typedHex(value, 128);
|
|
928
|
+
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
929
|
+
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
930
|
+
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
931
|
+
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
932
|
+
var CredentialType = Cardano.CredentialType;
|
|
933
|
+
var Certificate = Serialization.Certificate;
|
|
934
|
+
var PoolId = Cardano.PoolId;
|
|
935
|
+
var StakeRegistration = Serialization.StakeRegistration;
|
|
936
|
+
var StakeDelegation = Serialization.StakeDelegation;
|
|
937
|
+
var CertificateType = Cardano.CertificateType;
|
|
938
|
+
var VkeyWitness = Serialization.VkeyWitness;
|
|
939
|
+
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
940
|
+
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
941
|
+
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
942
|
+
var Bip32PrivateKey2 = Crypto.Bip32PrivateKey;
|
|
943
|
+
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
944
|
+
var PlutusLanguageVersion = Cardano.PlutusLanguageVersion;
|
|
945
|
+
var NativeScript = Serialization.NativeScript;
|
|
946
|
+
var PlutusV1Script = Serialization.PlutusV1Script;
|
|
947
|
+
var PlutusV2Script = Serialization.PlutusV2Script;
|
|
948
|
+
var PlutusV3Script = Serialization.PlutusV3Script;
|
|
949
|
+
var Costmdls = Serialization.Costmdls;
|
|
950
|
+
var CostModel = Serialization.CostModel;
|
|
951
|
+
var CborWriter = Serialization.CborWriter;
|
|
952
|
+
var ConstrPlutusData = Serialization.ConstrPlutusData;
|
|
953
|
+
var RewardAccount = Cardano.RewardAccount;
|
|
954
|
+
var Hash = Serialization.Hash;
|
|
955
|
+
var DatumHash = Crypto.Hash32ByteBase16;
|
|
956
|
+
var Datum = Serialization.Datum;
|
|
957
|
+
var ExUnits = Serialization.ExUnits;
|
|
958
|
+
var NetworkId = Cardano.NetworkId;
|
|
959
|
+
var DatumKind = Serialization.DatumKind;
|
|
960
|
+
var CborSet = Serialization.CborSet;
|
|
961
|
+
var RequireAllOf = Cardano.NativeScriptKind.RequireAllOf;
|
|
962
|
+
var RequireAnyOf = Cardano.NativeScriptKind.RequireAnyOf;
|
|
963
|
+
var RequireNOf = Cardano.NativeScriptKind.RequireNOf;
|
|
964
|
+
var RequireSignature = Cardano.NativeScriptKind.RequireSignature;
|
|
965
|
+
var RequireTimeAfter = Cardano.NativeScriptKind.RequireTimeAfter;
|
|
966
|
+
var RequireTimeBefore = Cardano.NativeScriptKind.RequireTimeBefore;
|
|
967
|
+
var VrfVkBech32 = Cardano.VrfVkBech32;
|
|
968
|
+
var ScriptPubkey = Serialization.ScriptPubkey;
|
|
969
|
+
var DRepID = Cardano.DRepID;
|
|
894
970
|
|
|
895
|
-
// src/
|
|
971
|
+
// src/message-signing/cose-sign1.ts
|
|
896
972
|
var import_blakejs = __toESM(require_blakejs(), 1);
|
|
897
973
|
import { Buffer as Buffer2 } from "buffer";
|
|
898
|
-
|
|
899
|
-
|
|
974
|
+
|
|
975
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
976
|
+
import strica2 from "@stricahq/bip32ed25519";
|
|
977
|
+
|
|
978
|
+
// src/stricahq/bip32ed25519/privateKey.ts
|
|
979
|
+
import strica from "@stricahq/bip32ed25519";
|
|
980
|
+
import hash from "hash.js";
|
|
981
|
+
var PrivateKey = class extends strica.PrivateKey {
|
|
982
|
+
constructor(privKey, extended = true) {
|
|
983
|
+
if (!extended) {
|
|
984
|
+
let extendedSecret = hash.sha512().update(privKey).digest();
|
|
985
|
+
if (extendedSecret[0] && extendedSecret[31]) {
|
|
986
|
+
extendedSecret[0] &= 248;
|
|
987
|
+
extendedSecret[31] &= 63;
|
|
988
|
+
extendedSecret[31] |= 64;
|
|
989
|
+
}
|
|
990
|
+
privKey = Buffer.from(extendedSecret);
|
|
991
|
+
}
|
|
992
|
+
super(privKey);
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
997
|
+
var { PublicKey, Bip32PrivateKey: Bip32PrivateKey3, Bip32PublicKey } = strica2;
|
|
998
|
+
|
|
999
|
+
// src/stricahq/cbors/index.ts
|
|
1000
|
+
import strica3 from "@stricahq/cbors";
|
|
1001
|
+
var { Encoder, Decoder } = strica3;
|
|
1002
|
+
|
|
1003
|
+
// src/message-signing/cose-sign1.ts
|
|
900
1004
|
var CoseSign1 = class _CoseSign1 {
|
|
901
1005
|
protectedMap;
|
|
902
1006
|
unProtectedMap;
|
|
@@ -1019,106 +1123,20 @@ var getCoseKeyFromPublicKey = (cbor) => {
|
|
|
1019
1123
|
return Encoder.encode(coseKeyMap);
|
|
1020
1124
|
};
|
|
1021
1125
|
|
|
1022
|
-
// src/
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
if (!extended) {
|
|
1028
|
-
let extendedSecret = hash.sha512().update(privKey).digest();
|
|
1029
|
-
if (extendedSecret[0] && extendedSecret[31]) {
|
|
1030
|
-
extendedSecret[0] &= 248;
|
|
1031
|
-
extendedSecret[31] &= 63;
|
|
1032
|
-
extendedSecret[31] |= 64;
|
|
1033
|
-
}
|
|
1034
|
-
privKey = Buffer.from(extendedSecret);
|
|
1035
|
-
}
|
|
1036
|
-
super(privKey);
|
|
1126
|
+
// src/message-signing/check-signature.ts
|
|
1127
|
+
var checkSignature = (data, { key, signature }) => {
|
|
1128
|
+
const builder = CoseSign1.fromCbor(signature);
|
|
1129
|
+
if (builder.getPayload() === null) {
|
|
1130
|
+
return false;
|
|
1037
1131
|
}
|
|
1132
|
+
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
return builder.verifySignature({
|
|
1136
|
+
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1137
|
+
});
|
|
1038
1138
|
};
|
|
1039
1139
|
|
|
1040
|
-
// src/stricahq/index.ts
|
|
1041
|
-
var { PublicKey: PublicKey2, Bip32PrivateKey, Bip32PublicKey } = strica2;
|
|
1042
|
-
|
|
1043
|
-
// src/types/cardano-sdk.ts
|
|
1044
|
-
import { Cardano, Serialization } from "@cardano-sdk/core";
|
|
1045
|
-
import * as Crypto from "@cardano-sdk/crypto";
|
|
1046
|
-
import { typedHex } from "@cardano-sdk/util";
|
|
1047
|
-
var Slot = Cardano.Slot;
|
|
1048
|
-
var Value = Serialization.Value;
|
|
1049
|
-
var Transaction = Serialization.Transaction;
|
|
1050
|
-
var TransactionId = Cardano.TransactionId;
|
|
1051
|
-
var TransactionBody = Serialization.TransactionBody;
|
|
1052
|
-
var TransactionWitnessSet = Serialization.TransactionWitnessSet;
|
|
1053
|
-
var TransactionUnspentOutput = Serialization.TransactionUnspentOutput;
|
|
1054
|
-
var TransactionInput = Serialization.TransactionInput;
|
|
1055
|
-
var TransactionOutput = Serialization.TransactionOutput;
|
|
1056
|
-
var PlutusData = Serialization.PlutusData;
|
|
1057
|
-
var PlutusList = Serialization.PlutusList;
|
|
1058
|
-
var PlutusMap = Serialization.PlutusMap;
|
|
1059
|
-
var Redeemers = Serialization.Redeemers;
|
|
1060
|
-
var Redeemer = Serialization.Redeemer;
|
|
1061
|
-
var RedeemerPurpose = Cardano.RedeemerPurpose;
|
|
1062
|
-
var RedeemerTag = Serialization.RedeemerTag;
|
|
1063
|
-
var Script = Serialization.Script;
|
|
1064
|
-
var PolicyId = Cardano.PolicyId;
|
|
1065
|
-
var AssetName = Cardano.AssetName;
|
|
1066
|
-
var AssetId = Cardano.AssetId;
|
|
1067
|
-
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
1068
|
-
var Address = Cardano.Address;
|
|
1069
|
-
var RewardAddress = Cardano.RewardAddress;
|
|
1070
|
-
var AddressType = Cardano.AddressType;
|
|
1071
|
-
var BaseAddress = Cardano.BaseAddress;
|
|
1072
|
-
var EnterpriseAddress = Cardano.EnterpriseAddress;
|
|
1073
|
-
var PaymentAddress = Cardano.PaymentAddress;
|
|
1074
|
-
var AssetFingerprint = Cardano.AssetFingerprint;
|
|
1075
|
-
var Credential = Serialization.Credential;
|
|
1076
|
-
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
1077
|
-
var Ed25519PrivateNormalKeyHex = (value) => typedHex(value, 64);
|
|
1078
|
-
var Ed25519PrivateExtendedKeyHex = (value) => typedHex(value, 128);
|
|
1079
|
-
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
1080
|
-
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
1081
|
-
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
1082
|
-
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
1083
|
-
var CredentialType = Cardano.CredentialType;
|
|
1084
|
-
var Certificate = Serialization.Certificate;
|
|
1085
|
-
var PoolId = Cardano.PoolId;
|
|
1086
|
-
var StakeRegistration = Serialization.StakeRegistration;
|
|
1087
|
-
var StakeDelegation = Serialization.StakeDelegation;
|
|
1088
|
-
var CertificateType = Cardano.CertificateType;
|
|
1089
|
-
var VkeyWitness = Serialization.VkeyWitness;
|
|
1090
|
-
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
1091
|
-
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
1092
|
-
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
1093
|
-
var Bip32PrivateKey3 = Crypto.Bip32PrivateKey;
|
|
1094
|
-
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
1095
|
-
var PlutusLanguageVersion = Cardano.PlutusLanguageVersion;
|
|
1096
|
-
var NativeScript = Serialization.NativeScript;
|
|
1097
|
-
var PlutusV1Script = Serialization.PlutusV1Script;
|
|
1098
|
-
var PlutusV2Script = Serialization.PlutusV2Script;
|
|
1099
|
-
var PlutusV3Script = Serialization.PlutusV3Script;
|
|
1100
|
-
var Costmdls = Serialization.Costmdls;
|
|
1101
|
-
var CostModel = Serialization.CostModel;
|
|
1102
|
-
var CborWriter = Serialization.CborWriter;
|
|
1103
|
-
var ConstrPlutusData = Serialization.ConstrPlutusData;
|
|
1104
|
-
var RewardAccount = Cardano.RewardAccount;
|
|
1105
|
-
var Hash = Serialization.Hash;
|
|
1106
|
-
var DatumHash = Crypto.Hash32ByteBase16;
|
|
1107
|
-
var Datum = Serialization.Datum;
|
|
1108
|
-
var ExUnits = Serialization.ExUnits;
|
|
1109
|
-
var NetworkId = Cardano.NetworkId;
|
|
1110
|
-
var DatumKind = Serialization.DatumKind;
|
|
1111
|
-
var CborSet = Serialization.CborSet;
|
|
1112
|
-
var RequireAllOf = Cardano.NativeScriptKind.RequireAllOf;
|
|
1113
|
-
var RequireAnyOf = Cardano.NativeScriptKind.RequireAnyOf;
|
|
1114
|
-
var RequireNOf = Cardano.NativeScriptKind.RequireNOf;
|
|
1115
|
-
var RequireSignature = Cardano.NativeScriptKind.RequireSignature;
|
|
1116
|
-
var RequireTimeAfter = Cardano.NativeScriptKind.RequireTimeAfter;
|
|
1117
|
-
var RequireTimeBefore = Cardano.NativeScriptKind.RequireTimeBefore;
|
|
1118
|
-
var VrfVkBech32 = Cardano.VrfVkBech32;
|
|
1119
|
-
var ScriptPubkey = Serialization.ScriptPubkey;
|
|
1120
|
-
var DRepID = Cardano.DRepID;
|
|
1121
|
-
|
|
1122
1140
|
// ../../node_modules/nanoid/index.js
|
|
1123
1141
|
import crypto from "crypto";
|
|
1124
1142
|
var POOL_SIZE_MULTIPLIER = 128;
|
|
@@ -1156,8 +1174,20 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
|
1156
1174
|
};
|
|
1157
1175
|
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
1158
1176
|
|
|
1159
|
-
// src/message-signing/
|
|
1177
|
+
// src/message-signing/generate-nonce.ts
|
|
1160
1178
|
import { stringToHex } from "@meshsdk/common";
|
|
1179
|
+
var generateNonce = (label = "", length = 32) => {
|
|
1180
|
+
if (length <= 0 || length > 2048) {
|
|
1181
|
+
throw new Error("Length must be bewteen 1 and 2048");
|
|
1182
|
+
}
|
|
1183
|
+
const randomString = customAlphabet(
|
|
1184
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1185
|
+
);
|
|
1186
|
+
const payload = randomString(length);
|
|
1187
|
+
return stringToHex(`${label}${payload}`);
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
// src/message-signing/sign-data.ts
|
|
1161
1191
|
var signData = (data, signer) => {
|
|
1162
1192
|
const payload = Buffer.from(data, "hex");
|
|
1163
1193
|
const publicKey = signer.key.toPublicKey().toBytes();
|
|
@@ -1177,28 +1207,6 @@ var signData = (data, signer) => {
|
|
|
1177
1207
|
signature: coseSignature
|
|
1178
1208
|
};
|
|
1179
1209
|
};
|
|
1180
|
-
var checkSignature = (data, { key, signature }) => {
|
|
1181
|
-
const builder = CoseSign1.fromCbor(signature);
|
|
1182
|
-
if (builder.getPayload() === null) {
|
|
1183
|
-
return false;
|
|
1184
|
-
}
|
|
1185
|
-
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1186
|
-
return false;
|
|
1187
|
-
}
|
|
1188
|
-
return builder.verifySignature({
|
|
1189
|
-
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1190
|
-
});
|
|
1191
|
-
};
|
|
1192
|
-
var generateNonce = (label = "", length = 32) => {
|
|
1193
|
-
if (length <= 0 || length > 2048) {
|
|
1194
|
-
throw new Error("Length must be bewteen 1 and 2048");
|
|
1195
|
-
}
|
|
1196
|
-
const randomString = customAlphabet(
|
|
1197
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1198
|
-
);
|
|
1199
|
-
const payload = randomString(length);
|
|
1200
|
-
return stringToHex(`${label}${payload}`);
|
|
1201
|
-
};
|
|
1202
1210
|
|
|
1203
1211
|
// src/resolvers/index.ts
|
|
1204
1212
|
import { Cardano as Cardano2 } from "@cardano-sdk/core";
|
|
@@ -1251,7 +1259,7 @@ var buildBip32PrivateKey = (entropy, password = "") => {
|
|
|
1251
1259
|
PBKDF2_KEY_SIZE,
|
|
1252
1260
|
PBKDF2_DIGEST_ALGORITHM
|
|
1253
1261
|
);
|
|
1254
|
-
return
|
|
1262
|
+
return Bip32PrivateKey2.fromBytes(clampScalar(xprv));
|
|
1255
1263
|
};
|
|
1256
1264
|
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
1257
1265
|
const cred = {
|
|
@@ -1262,7 +1270,7 @@ var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
|
1262
1270
|
};
|
|
1263
1271
|
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
1264
1272
|
if (typeof entropy === "string") {
|
|
1265
|
-
const rootKey = new
|
|
1273
|
+
const rootKey = new Bip32PrivateKey3(Buffer.from(entropy, "hex"));
|
|
1266
1274
|
const accountKey = rootKey.derive(HARDENED_KEY_START + 1852).derive(HARDENED_KEY_START + 1815).derive(HARDENED_KEY_START + accountIndex);
|
|
1267
1275
|
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
1268
1276
|
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
@@ -2542,7 +2550,7 @@ export {
|
|
|
2542
2550
|
AssetId,
|
|
2543
2551
|
AssetName,
|
|
2544
2552
|
BaseAddress,
|
|
2545
|
-
|
|
2553
|
+
Bip32PrivateKey2 as Bip32PrivateKey,
|
|
2546
2554
|
Bip32PrivateKeyHex2 as Bip32PrivateKeyHex,
|
|
2547
2555
|
Cardano4 as Cardano,
|
|
2548
2556
|
CardanoSDK,
|
|
@@ -2553,6 +2561,7 @@ export {
|
|
|
2553
2561
|
Certificate,
|
|
2554
2562
|
CertificateType,
|
|
2555
2563
|
ConstrPlutusData,
|
|
2564
|
+
CoseSign1,
|
|
2556
2565
|
CostModel,
|
|
2557
2566
|
Costmdls,
|
|
2558
2567
|
Credential,
|
|
@@ -2606,11 +2615,12 @@ export {
|
|
|
2606
2615
|
Slot,
|
|
2607
2616
|
StakeDelegation,
|
|
2608
2617
|
StakeRegistration,
|
|
2609
|
-
|
|
2618
|
+
Bip32PrivateKey3 as StricaBip32PrivateKey,
|
|
2610
2619
|
Bip32PublicKey as StricaBip32PublicKey,
|
|
2611
|
-
|
|
2620
|
+
Decoder as StricaDecoder,
|
|
2621
|
+
Encoder as StricaEncoder,
|
|
2612
2622
|
PrivateKey as StricaPrivateKey,
|
|
2613
|
-
|
|
2623
|
+
PublicKey as StricaPublicKey,
|
|
2614
2624
|
Transaction,
|
|
2615
2625
|
TransactionBody,
|
|
2616
2626
|
TransactionId,
|