@meshsdk/core-cst 1.6.3 → 1.6.5
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 +144 -150
- package/dist/index.d.cts +41 -41
- package/dist/index.d.ts +41 -41
- package/dist/index.js +142 -147
- package/package.json +4 -1
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,11 +912,13 @@ __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,
|
|
918
919
|
CredentialType: () => CredentialType,
|
|
919
920
|
Crypto: () => Crypto3,
|
|
921
|
+
DRep: () => DRep,
|
|
920
922
|
DRepID: () => DRepID,
|
|
921
923
|
Datum: () => Datum,
|
|
922
924
|
DatumHash: () => DatumHash,
|
|
@@ -963,13 +965,15 @@ __export(src_exports, {
|
|
|
963
965
|
ScriptPubkey: () => ScriptPubkey,
|
|
964
966
|
Serialization: () => import_core7.Serialization,
|
|
965
967
|
Slot: () => Slot,
|
|
968
|
+
StakeCredentialStatus: () => StakeCredentialStatus,
|
|
966
969
|
StakeDelegation: () => StakeDelegation,
|
|
967
970
|
StakeRegistration: () => StakeRegistration,
|
|
968
|
-
StricaBip32PrivateKey: () => Bip32PrivateKey,
|
|
969
|
-
StricaBip32PublicKey: () => Bip32PublicKey,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
971
|
+
StricaBip32PrivateKey: () => import_bip32ed25519.Bip32PrivateKey,
|
|
972
|
+
StricaBip32PublicKey: () => import_bip32ed25519.Bip32PublicKey,
|
|
973
|
+
StricaDecoder: () => import_cbors.Decoder,
|
|
974
|
+
StricaEncoder: () => import_cbors.Encoder,
|
|
975
|
+
StricaPrivateKey: () => import_bip32ed25519.PrivateKey,
|
|
976
|
+
StricaPublicKey: () => import_bip32ed25519.PublicKey,
|
|
973
977
|
Transaction: () => Transaction,
|
|
974
978
|
TransactionBody: () => TransactionBody,
|
|
975
979
|
TransactionId: () => TransactionId,
|
|
@@ -1040,14 +1044,98 @@ __export(src_exports, {
|
|
|
1040
1044
|
module.exports = __toCommonJS(src_exports);
|
|
1041
1045
|
var import_core7 = require("@cardano-sdk/core");
|
|
1042
1046
|
|
|
1043
|
-
// src/
|
|
1044
|
-
var
|
|
1047
|
+
// src/types/cardano-sdk.ts
|
|
1048
|
+
var import_core = require("@cardano-sdk/core");
|
|
1049
|
+
var Crypto = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
1050
|
+
var import_util = require("@cardano-sdk/util");
|
|
1051
|
+
var Slot = import_core.Cardano.Slot;
|
|
1052
|
+
var Value = import_core.Serialization.Value;
|
|
1053
|
+
var Transaction = import_core.Serialization.Transaction;
|
|
1054
|
+
var TransactionId = import_core.Cardano.TransactionId;
|
|
1055
|
+
var TransactionBody = import_core.Serialization.TransactionBody;
|
|
1056
|
+
var TransactionWitnessSet = import_core.Serialization.TransactionWitnessSet;
|
|
1057
|
+
var TransactionUnspentOutput = import_core.Serialization.TransactionUnspentOutput;
|
|
1058
|
+
var TransactionInput = import_core.Serialization.TransactionInput;
|
|
1059
|
+
var TransactionOutput = import_core.Serialization.TransactionOutput;
|
|
1060
|
+
var PlutusData = import_core.Serialization.PlutusData;
|
|
1061
|
+
var PlutusList = import_core.Serialization.PlutusList;
|
|
1062
|
+
var PlutusMap = import_core.Serialization.PlutusMap;
|
|
1063
|
+
var Redeemers = import_core.Serialization.Redeemers;
|
|
1064
|
+
var Redeemer = import_core.Serialization.Redeemer;
|
|
1065
|
+
var RedeemerPurpose = import_core.Cardano.RedeemerPurpose;
|
|
1066
|
+
var RedeemerTag = import_core.Serialization.RedeemerTag;
|
|
1067
|
+
var Script = import_core.Serialization.Script;
|
|
1068
|
+
var PolicyId = import_core.Cardano.PolicyId;
|
|
1069
|
+
var AssetName = import_core.Cardano.AssetName;
|
|
1070
|
+
var AssetId = import_core.Cardano.AssetId;
|
|
1071
|
+
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
1072
|
+
var Address = import_core.Cardano.Address;
|
|
1073
|
+
var RewardAddress = import_core.Cardano.RewardAddress;
|
|
1074
|
+
var AddressType = import_core.Cardano.AddressType;
|
|
1075
|
+
var BaseAddress = import_core.Cardano.BaseAddress;
|
|
1076
|
+
var EnterpriseAddress = import_core.Cardano.EnterpriseAddress;
|
|
1077
|
+
var PaymentAddress = import_core.Cardano.PaymentAddress;
|
|
1078
|
+
var AssetFingerprint = import_core.Cardano.AssetFingerprint;
|
|
1079
|
+
var Credential = import_core.Serialization.Credential;
|
|
1080
|
+
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
1081
|
+
var Ed25519PrivateNormalKeyHex = (value) => (0, import_util.typedHex)(value, 64);
|
|
1082
|
+
var Ed25519PrivateExtendedKeyHex = (value) => (0, import_util.typedHex)(value, 128);
|
|
1083
|
+
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
1084
|
+
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
1085
|
+
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
1086
|
+
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
1087
|
+
var CredentialType = import_core.Cardano.CredentialType;
|
|
1088
|
+
var Certificate = import_core.Serialization.Certificate;
|
|
1089
|
+
var PoolId = import_core.Cardano.PoolId;
|
|
1090
|
+
var StakeRegistration = import_core.Serialization.StakeRegistration;
|
|
1091
|
+
var StakeDelegation = import_core.Serialization.StakeDelegation;
|
|
1092
|
+
var CertificateType = import_core.Cardano.CertificateType;
|
|
1093
|
+
var VkeyWitness = import_core.Serialization.VkeyWitness;
|
|
1094
|
+
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
1095
|
+
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
1096
|
+
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
1097
|
+
var Bip32PrivateKey2 = Crypto.Bip32PrivateKey;
|
|
1098
|
+
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
1099
|
+
var PlutusLanguageVersion = import_core.Cardano.PlutusLanguageVersion;
|
|
1100
|
+
var NativeScript = import_core.Serialization.NativeScript;
|
|
1101
|
+
var PlutusV1Script = import_core.Serialization.PlutusV1Script;
|
|
1102
|
+
var PlutusV2Script = import_core.Serialization.PlutusV2Script;
|
|
1103
|
+
var PlutusV3Script = import_core.Serialization.PlutusV3Script;
|
|
1104
|
+
var Costmdls = import_core.Serialization.Costmdls;
|
|
1105
|
+
var CostModel = import_core.Serialization.CostModel;
|
|
1106
|
+
var CborWriter = import_core.Serialization.CborWriter;
|
|
1107
|
+
var ConstrPlutusData = import_core.Serialization.ConstrPlutusData;
|
|
1108
|
+
var RewardAccount = import_core.Cardano.RewardAccount;
|
|
1109
|
+
var Hash = import_core.Serialization.Hash;
|
|
1110
|
+
var DatumHash = Crypto.Hash32ByteBase16;
|
|
1111
|
+
var Datum = import_core.Serialization.Datum;
|
|
1112
|
+
var ExUnits = import_core.Serialization.ExUnits;
|
|
1113
|
+
var NetworkId = import_core.Cardano.NetworkId;
|
|
1114
|
+
var DatumKind = import_core.Serialization.DatumKind;
|
|
1115
|
+
var CborSet = import_core.Serialization.CborSet;
|
|
1116
|
+
var RequireAllOf = import_core.Cardano.NativeScriptKind.RequireAllOf;
|
|
1117
|
+
var RequireAnyOf = import_core.Cardano.NativeScriptKind.RequireAnyOf;
|
|
1118
|
+
var RequireNOf = import_core.Cardano.NativeScriptKind.RequireNOf;
|
|
1119
|
+
var RequireSignature = import_core.Cardano.NativeScriptKind.RequireSignature;
|
|
1120
|
+
var RequireTimeAfter = import_core.Cardano.NativeScriptKind.RequireTimeAfter;
|
|
1121
|
+
var RequireTimeBefore = import_core.Cardano.NativeScriptKind.RequireTimeBefore;
|
|
1122
|
+
var VrfVkBech32 = import_core.Cardano.VrfVkBech32;
|
|
1123
|
+
var ScriptPubkey = import_core.Serialization.ScriptPubkey;
|
|
1124
|
+
var DRepID = import_core.Cardano.DRepID;
|
|
1125
|
+
var DRep = import_core.Serialization.DRep;
|
|
1126
|
+
var StakeCredentialStatus = import_core.Cardano.StakeCredentialStatus;
|
|
1045
1127
|
|
|
1046
|
-
// src/
|
|
1128
|
+
// src/message-signing/cose-sign1.ts
|
|
1047
1129
|
var import_buffer = require("buffer");
|
|
1130
|
+
var import_blakejs = __toESM(require_blakejs(), 1);
|
|
1131
|
+
|
|
1132
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
1048
1133
|
var import_bip32ed25519 = require("@stricahq/bip32ed25519");
|
|
1134
|
+
|
|
1135
|
+
// src/stricahq/cbors/index.ts
|
|
1049
1136
|
var import_cbors = require("@stricahq/cbors");
|
|
1050
|
-
|
|
1137
|
+
|
|
1138
|
+
// src/message-signing/cose-sign1.ts
|
|
1051
1139
|
var CoseSign1 = class _CoseSign1 {
|
|
1052
1140
|
protectedMap;
|
|
1053
1141
|
unProtectedMap;
|
|
@@ -1137,8 +1225,8 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
1137
1225
|
if (this.unProtectedMap.get("hashed") != false)
|
|
1138
1226
|
throw Error("Invalid unprotected map");
|
|
1139
1227
|
this.unProtectedMap.set("hashed", true);
|
|
1140
|
-
const
|
|
1141
|
-
this.payload = import_buffer.Buffer.from(
|
|
1228
|
+
const hash = (0, import_blakejs.blake2b)(this.payload, void 0, 24);
|
|
1229
|
+
this.payload = import_buffer.Buffer.from(hash);
|
|
1142
1230
|
}
|
|
1143
1231
|
getAddress() {
|
|
1144
1232
|
return this.protectedMap.get("address");
|
|
@@ -1170,106 +1258,20 @@ var getCoseKeyFromPublicKey = (cbor) => {
|
|
|
1170
1258
|
return import_cbors.Encoder.encode(coseKeyMap);
|
|
1171
1259
|
};
|
|
1172
1260
|
|
|
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);
|
|
1261
|
+
// src/message-signing/check-signature.ts
|
|
1262
|
+
var checkSignature = (data, { key, signature }) => {
|
|
1263
|
+
const builder = CoseSign1.fromCbor(signature);
|
|
1264
|
+
if (builder.getPayload() === null) {
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1268
|
+
return false;
|
|
1188
1269
|
}
|
|
1270
|
+
return builder.verifySignature({
|
|
1271
|
+
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1272
|
+
});
|
|
1189
1273
|
};
|
|
1190
1274
|
|
|
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
1275
|
// ../../node_modules/nanoid/index.js
|
|
1274
1276
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
1275
1277
|
var POOL_SIZE_MULTIPLIER = 128;
|
|
@@ -1307,8 +1309,20 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
|
1307
1309
|
};
|
|
1308
1310
|
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
1309
1311
|
|
|
1310
|
-
// src/message-signing/
|
|
1312
|
+
// src/message-signing/generate-nonce.ts
|
|
1311
1313
|
var import_common = require("@meshsdk/common");
|
|
1314
|
+
var generateNonce = (label = "", length = 32) => {
|
|
1315
|
+
if (length <= 0 || length > 2048) {
|
|
1316
|
+
throw new Error("Length must be bewteen 1 and 2048");
|
|
1317
|
+
}
|
|
1318
|
+
const randomString = customAlphabet(
|
|
1319
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1320
|
+
);
|
|
1321
|
+
const payload = randomString(length);
|
|
1322
|
+
return (0, import_common.stringToHex)(`${label}${payload}`);
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
// src/message-signing/sign-data.ts
|
|
1312
1326
|
var signData = (data, signer) => {
|
|
1313
1327
|
const payload = Buffer.from(data, "hex");
|
|
1314
1328
|
const publicKey = signer.key.toPublicKey().toBytes();
|
|
@@ -1328,28 +1342,6 @@ var signData = (data, signer) => {
|
|
|
1328
1342
|
signature: coseSignature
|
|
1329
1343
|
};
|
|
1330
1344
|
};
|
|
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
1345
|
|
|
1354
1346
|
// src/resolvers/index.ts
|
|
1355
1347
|
var import_core4 = require("@cardano-sdk/core");
|
|
@@ -1402,7 +1394,7 @@ var buildBip32PrivateKey = (entropy, password = "") => {
|
|
|
1402
1394
|
PBKDF2_KEY_SIZE,
|
|
1403
1395
|
PBKDF2_DIGEST_ALGORITHM
|
|
1404
1396
|
);
|
|
1405
|
-
return
|
|
1397
|
+
return Bip32PrivateKey2.fromBytes(clampScalar(xprv));
|
|
1406
1398
|
};
|
|
1407
1399
|
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
1408
1400
|
const cred = {
|
|
@@ -1413,19 +1405,18 @@ var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
|
1413
1405
|
};
|
|
1414
1406
|
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
1415
1407
|
if (typeof entropy === "string") {
|
|
1416
|
-
const rootKey = new Bip32PrivateKey(Buffer.from(entropy, "hex"));
|
|
1408
|
+
const rootKey = new import_bip32ed25519.Bip32PrivateKey(Buffer.from(entropy, "hex"));
|
|
1417
1409
|
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
1410
|
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
1419
1411
|
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
1420
|
-
|
|
1412
|
+
const dRepKey = accountKey.derive(3).derive(keyIndex).toPrivateKey();
|
|
1413
|
+
return { paymentKey, stakeKey, dRepKey };
|
|
1421
1414
|
} else {
|
|
1422
|
-
const paymentKey =
|
|
1423
|
-
Buffer.from(entropy[0], "hex")
|
|
1424
|
-
false
|
|
1415
|
+
const paymentKey = import_bip32ed25519.PrivateKey.fromSecretKey(
|
|
1416
|
+
Buffer.from(entropy[0], "hex")
|
|
1425
1417
|
);
|
|
1426
|
-
const stakeKey =
|
|
1427
|
-
Buffer.from(entropy[1], "hex")
|
|
1428
|
-
false
|
|
1418
|
+
const stakeKey = import_bip32ed25519.PrivateKey.fromSecretKey(
|
|
1419
|
+
Buffer.from(entropy[1], "hex")
|
|
1429
1420
|
);
|
|
1430
1421
|
return { paymentKey, stakeKey };
|
|
1431
1422
|
}
|
|
@@ -1866,8 +1857,8 @@ var resolvePlutusScriptHash = (bech32) => {
|
|
|
1866
1857
|
throw new Error(`An error occurred during resolveScriptHash: ${error}.`);
|
|
1867
1858
|
}
|
|
1868
1859
|
};
|
|
1869
|
-
var resolvePoolId = (
|
|
1870
|
-
return Ed25519KeyHashHex2(
|
|
1860
|
+
var resolvePoolId = (hash) => {
|
|
1861
|
+
return Ed25519KeyHashHex2(hash).toString();
|
|
1871
1862
|
};
|
|
1872
1863
|
var resolvePrivateKey = (words) => {
|
|
1873
1864
|
return "not implemented";
|
|
@@ -1901,8 +1892,8 @@ var resolveStakeKeyHash = (bech32) => {
|
|
|
1901
1892
|
};
|
|
1902
1893
|
var resolveTxHash = (txHex) => {
|
|
1903
1894
|
const txBody = deserializeTx(txHex).body();
|
|
1904
|
-
const
|
|
1905
|
-
return import_core4.Cardano.TransactionId.fromHexBlob(import_util5.HexBlob.fromBytes(
|
|
1895
|
+
const hash = (0, import_crypto5.blake2b)(import_crypto5.blake2b.BYTES).update(hexToBytes(txBody.toCbor())).digest();
|
|
1896
|
+
return import_core4.Cardano.TransactionId.fromHexBlob(import_util5.HexBlob.fromBytes(hash));
|
|
1906
1897
|
};
|
|
1907
1898
|
|
|
1908
1899
|
// src/serializer/index.ts
|
|
@@ -1972,7 +1963,7 @@ var CardanoSDKSerializer = class {
|
|
|
1972
1963
|
serializeRewardAddress(stakeKeyHash, isScriptHash, network_id) {
|
|
1973
1964
|
throw new Error("Method not implemented.");
|
|
1974
1965
|
}
|
|
1975
|
-
serializePoolId(
|
|
1966
|
+
serializePoolId(hash) {
|
|
1976
1967
|
throw new Error("Method not implemented.");
|
|
1977
1968
|
}
|
|
1978
1969
|
serializeAddress(address, networkId) {
|
|
@@ -2099,9 +2090,8 @@ var CardanoSDKSerializer = class {
|
|
|
2099
2090
|
if (keyHex.length === 68 && keyHex.substring(0, 4) === "5820") {
|
|
2100
2091
|
keyHex = keyHex.substring(4);
|
|
2101
2092
|
}
|
|
2102
|
-
const cardanoSigner =
|
|
2103
|
-
Buffer.from(keyHex, "hex")
|
|
2104
|
-
false
|
|
2093
|
+
const cardanoSigner = import_bip32ed25519.PrivateKey.fromSecretKey(
|
|
2094
|
+
Buffer.from(keyHex, "hex")
|
|
2105
2095
|
);
|
|
2106
2096
|
const signature = cardanoSigner.sign(
|
|
2107
2097
|
Buffer.from(cardanoTx.getId(), "hex")
|
|
@@ -2700,11 +2690,13 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
|
2700
2690
|
Certificate,
|
|
2701
2691
|
CertificateType,
|
|
2702
2692
|
ConstrPlutusData,
|
|
2693
|
+
CoseSign1,
|
|
2703
2694
|
CostModel,
|
|
2704
2695
|
Costmdls,
|
|
2705
2696
|
Credential,
|
|
2706
2697
|
CredentialType,
|
|
2707
2698
|
Crypto,
|
|
2699
|
+
DRep,
|
|
2708
2700
|
DRepID,
|
|
2709
2701
|
Datum,
|
|
2710
2702
|
DatumHash,
|
|
@@ -2751,11 +2743,13 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
|
2751
2743
|
ScriptPubkey,
|
|
2752
2744
|
Serialization,
|
|
2753
2745
|
Slot,
|
|
2746
|
+
StakeCredentialStatus,
|
|
2754
2747
|
StakeDelegation,
|
|
2755
2748
|
StakeRegistration,
|
|
2756
2749
|
StricaBip32PrivateKey,
|
|
2757
2750
|
StricaBip32PublicKey,
|
|
2758
|
-
|
|
2751
|
+
StricaDecoder,
|
|
2752
|
+
StricaEncoder,
|
|
2759
2753
|
StricaPrivateKey,
|
|
2760
2754
|
StricaPublicKey,
|
|
2761
2755
|
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 { PrivateKey } from '@stricahq/bip32ed25519';
|
|
11
|
+
export { Bip32PrivateKey as StricaBip32PrivateKey, Bip32PublicKey as StricaBip32PublicKey, PrivateKey as StricaPrivateKey, PublicKey as StricaPublicKey } from '@stricahq/bip32ed25519';
|
|
11
12
|
import { DataSignature, Data, NativeScript as NativeScript$1, PlutusScript, IMeshTxSerializer, DeserializedAddress, BuilderData, IDeserializer, IResolver, MeshTxBuilderBody, Protocol, UTxO, Asset, LanguageVersion } from '@meshsdk/common';
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
declare class CoseSign1 {
|
|
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 { Buffer } from 'buffer';
|
|
14
|
+
export { Decoder as StricaDecoder, Encoder as StricaEncoder } from '@stricahq/cbors';
|
|
49
15
|
|
|
50
16
|
declare const Slot: (value: number) => Cardano.Slot;
|
|
51
17
|
type Slot = Cardano.Slot;
|
|
@@ -245,16 +211,49 @@ declare const DRepID: {
|
|
|
245
211
|
isValid(value: string): boolean;
|
|
246
212
|
canSign(value: string): boolean;
|
|
247
213
|
};
|
|
214
|
+
type DRep = Serialization.DRep;
|
|
215
|
+
declare const DRep: typeof Serialization.DRep;
|
|
216
|
+
type StakeCredentialStatus = Cardano.StakeCredentialStatus;
|
|
217
|
+
declare const StakeCredentialStatus: typeof Cardano.StakeCredentialStatus;
|
|
248
218
|
|
|
249
219
|
type Signer = {
|
|
250
220
|
address: Address;
|
|
251
221
|
key: PrivateKey;
|
|
252
222
|
};
|
|
253
223
|
|
|
254
|
-
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
255
224
|
declare const checkSignature: (data: string, { key, signature }: DataSignature) => boolean;
|
|
225
|
+
|
|
226
|
+
declare class CoseSign1 {
|
|
227
|
+
private protectedMap;
|
|
228
|
+
private unProtectedMap;
|
|
229
|
+
private payload;
|
|
230
|
+
private signature;
|
|
231
|
+
constructor(payload: {
|
|
232
|
+
protectedMap: Map<any, any>;
|
|
233
|
+
unProtectedMap: Map<any, any>;
|
|
234
|
+
payload: Buffer | null;
|
|
235
|
+
signature?: Buffer;
|
|
236
|
+
});
|
|
237
|
+
static fromCbor(cbor: string): CoseSign1;
|
|
238
|
+
createSigStructure(externalAad?: Buffer): Buffer;
|
|
239
|
+
buildMessage(signature: Buffer): Buffer;
|
|
240
|
+
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
241
|
+
externalAad?: Buffer;
|
|
242
|
+
publicKeyBuffer?: Buffer;
|
|
243
|
+
}): boolean;
|
|
244
|
+
hashPayload(): void;
|
|
245
|
+
getAddress(): Buffer;
|
|
246
|
+
getPublicKey(): Buffer;
|
|
247
|
+
getSignature(): Buffer | undefined;
|
|
248
|
+
getPayload(): Buffer | null;
|
|
249
|
+
}
|
|
250
|
+
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer;
|
|
251
|
+
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer;
|
|
252
|
+
|
|
256
253
|
declare const generateNonce: (label?: string, length?: number) => string;
|
|
257
254
|
|
|
255
|
+
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
256
|
+
|
|
258
257
|
declare const resolveDataHash: (data: Data) => string;
|
|
259
258
|
declare const resolveNativeScriptAddress: (script: NativeScript$1, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
260
259
|
declare const resolveNativeScriptHash: (script: NativeScript$1) => string;
|
|
@@ -310,9 +309,10 @@ declare const buildRewardAddress: (networkId: number, stakeKeyHash: Hash28ByteBa
|
|
|
310
309
|
declare const buildKeys: (entropy: string | [string, string], accountIndex: number, keyIndex?: number) => {
|
|
311
310
|
paymentKey: PrivateKey;
|
|
312
311
|
stakeKey: PrivateKey;
|
|
312
|
+
dRepKey?: PrivateKey;
|
|
313
313
|
};
|
|
314
314
|
declare const buildScriptPubkey: (keyHash: Ed25519KeyHash) => NativeScript;
|
|
315
|
-
declare const buildDRepID: (dRepKey: Ed25519PublicKeyHex, networkId?: NetworkId, addressType?: AddressType) =>
|
|
315
|
+
declare const buildDRepID: (dRepKey: Ed25519PublicKeyHex, networkId?: NetworkId, addressType?: AddressType) => DRepID;
|
|
316
316
|
|
|
317
317
|
declare const toAddress: (bech32: string) => Address;
|
|
318
318
|
declare const toBaseAddress: (bech32: string) => BaseAddress | undefined;
|
|
@@ -349,4 +349,4 @@ declare function negatives(v: Value): Value;
|
|
|
349
349
|
declare function assetTypes(v: Value): number;
|
|
350
350
|
declare function empty(v: Value): boolean;
|
|
351
351
|
|
|
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,
|
|
352
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, 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, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, 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 { PrivateKey } from '@stricahq/bip32ed25519';
|
|
11
|
+
export { Bip32PrivateKey as StricaBip32PrivateKey, Bip32PublicKey as StricaBip32PublicKey, PrivateKey as StricaPrivateKey, PublicKey as StricaPublicKey } from '@stricahq/bip32ed25519';
|
|
11
12
|
import { DataSignature, Data, NativeScript as NativeScript$1, PlutusScript, IMeshTxSerializer, DeserializedAddress, BuilderData, IDeserializer, IResolver, MeshTxBuilderBody, Protocol, UTxO, Asset, LanguageVersion } from '@meshsdk/common';
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
declare class CoseSign1 {
|
|
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 { Buffer } from 'buffer';
|
|
14
|
+
export { Decoder as StricaDecoder, Encoder as StricaEncoder } from '@stricahq/cbors';
|
|
49
15
|
|
|
50
16
|
declare const Slot: (value: number) => Cardano.Slot;
|
|
51
17
|
type Slot = Cardano.Slot;
|
|
@@ -245,16 +211,49 @@ declare const DRepID: {
|
|
|
245
211
|
isValid(value: string): boolean;
|
|
246
212
|
canSign(value: string): boolean;
|
|
247
213
|
};
|
|
214
|
+
type DRep = Serialization.DRep;
|
|
215
|
+
declare const DRep: typeof Serialization.DRep;
|
|
216
|
+
type StakeCredentialStatus = Cardano.StakeCredentialStatus;
|
|
217
|
+
declare const StakeCredentialStatus: typeof Cardano.StakeCredentialStatus;
|
|
248
218
|
|
|
249
219
|
type Signer = {
|
|
250
220
|
address: Address;
|
|
251
221
|
key: PrivateKey;
|
|
252
222
|
};
|
|
253
223
|
|
|
254
|
-
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
255
224
|
declare const checkSignature: (data: string, { key, signature }: DataSignature) => boolean;
|
|
225
|
+
|
|
226
|
+
declare class CoseSign1 {
|
|
227
|
+
private protectedMap;
|
|
228
|
+
private unProtectedMap;
|
|
229
|
+
private payload;
|
|
230
|
+
private signature;
|
|
231
|
+
constructor(payload: {
|
|
232
|
+
protectedMap: Map<any, any>;
|
|
233
|
+
unProtectedMap: Map<any, any>;
|
|
234
|
+
payload: Buffer | null;
|
|
235
|
+
signature?: Buffer;
|
|
236
|
+
});
|
|
237
|
+
static fromCbor(cbor: string): CoseSign1;
|
|
238
|
+
createSigStructure(externalAad?: Buffer): Buffer;
|
|
239
|
+
buildMessage(signature: Buffer): Buffer;
|
|
240
|
+
verifySignature({ externalAad, publicKeyBuffer, }?: {
|
|
241
|
+
externalAad?: Buffer;
|
|
242
|
+
publicKeyBuffer?: Buffer;
|
|
243
|
+
}): boolean;
|
|
244
|
+
hashPayload(): void;
|
|
245
|
+
getAddress(): Buffer;
|
|
246
|
+
getPublicKey(): Buffer;
|
|
247
|
+
getSignature(): Buffer | undefined;
|
|
248
|
+
getPayload(): Buffer | null;
|
|
249
|
+
}
|
|
250
|
+
declare const getPublicKeyFromCoseKey: (cbor: string) => Buffer;
|
|
251
|
+
declare const getCoseKeyFromPublicKey: (cbor: string) => Buffer;
|
|
252
|
+
|
|
256
253
|
declare const generateNonce: (label?: string, length?: number) => string;
|
|
257
254
|
|
|
255
|
+
declare const signData: (data: string, signer: Signer) => DataSignature;
|
|
256
|
+
|
|
258
257
|
declare const resolveDataHash: (data: Data) => string;
|
|
259
258
|
declare const resolveNativeScriptAddress: (script: NativeScript$1, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
260
259
|
declare const resolveNativeScriptHash: (script: NativeScript$1) => string;
|
|
@@ -310,9 +309,10 @@ declare const buildRewardAddress: (networkId: number, stakeKeyHash: Hash28ByteBa
|
|
|
310
309
|
declare const buildKeys: (entropy: string | [string, string], accountIndex: number, keyIndex?: number) => {
|
|
311
310
|
paymentKey: PrivateKey;
|
|
312
311
|
stakeKey: PrivateKey;
|
|
312
|
+
dRepKey?: PrivateKey;
|
|
313
313
|
};
|
|
314
314
|
declare const buildScriptPubkey: (keyHash: Ed25519KeyHash) => NativeScript;
|
|
315
|
-
declare const buildDRepID: (dRepKey: Ed25519PublicKeyHex, networkId?: NetworkId, addressType?: AddressType) =>
|
|
315
|
+
declare const buildDRepID: (dRepKey: Ed25519PublicKeyHex, networkId?: NetworkId, addressType?: AddressType) => DRepID;
|
|
316
316
|
|
|
317
317
|
declare const toAddress: (bech32: string) => Address;
|
|
318
318
|
declare const toBaseAddress: (bech32: string) => BaseAddress | undefined;
|
|
@@ -349,4 +349,4 @@ declare function negatives(v: Value): Value;
|
|
|
349
349
|
declare function assetTypes(v: Value): number;
|
|
350
350
|
declare function empty(v: Value): boolean;
|
|
351
351
|
|
|
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,
|
|
352
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, 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, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, 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,103 @@ 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;
|
|
970
|
+
var DRep = Serialization.DRep;
|
|
971
|
+
var StakeCredentialStatus = Cardano.StakeCredentialStatus;
|
|
894
972
|
|
|
895
|
-
// src/
|
|
973
|
+
// src/message-signing/cose-sign1.ts
|
|
896
974
|
var import_blakejs = __toESM(require_blakejs(), 1);
|
|
897
975
|
import { Buffer as Buffer2 } from "buffer";
|
|
898
|
-
|
|
976
|
+
|
|
977
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
978
|
+
import {
|
|
979
|
+
Bip32PrivateKey as Bip32PrivateKey3,
|
|
980
|
+
Bip32PublicKey,
|
|
981
|
+
PrivateKey,
|
|
982
|
+
PublicKey
|
|
983
|
+
} from "@stricahq/bip32ed25519";
|
|
984
|
+
|
|
985
|
+
// src/stricahq/cbors/index.ts
|
|
899
986
|
import { Decoder, Encoder } from "@stricahq/cbors";
|
|
987
|
+
|
|
988
|
+
// src/message-signing/cose-sign1.ts
|
|
900
989
|
var CoseSign1 = class _CoseSign1 {
|
|
901
990
|
protectedMap;
|
|
902
991
|
unProtectedMap;
|
|
@@ -986,8 +1075,8 @@ var CoseSign1 = class _CoseSign1 {
|
|
|
986
1075
|
if (this.unProtectedMap.get("hashed") != false)
|
|
987
1076
|
throw Error("Invalid unprotected map");
|
|
988
1077
|
this.unProtectedMap.set("hashed", true);
|
|
989
|
-
const
|
|
990
|
-
this.payload = Buffer2.from(
|
|
1078
|
+
const hash = (0, import_blakejs.blake2b)(this.payload, void 0, 24);
|
|
1079
|
+
this.payload = Buffer2.from(hash);
|
|
991
1080
|
}
|
|
992
1081
|
getAddress() {
|
|
993
1082
|
return this.protectedMap.get("address");
|
|
@@ -1019,106 +1108,20 @@ var getCoseKeyFromPublicKey = (cbor) => {
|
|
|
1019
1108
|
return Encoder.encode(coseKeyMap);
|
|
1020
1109
|
};
|
|
1021
1110
|
|
|
1022
|
-
// src/
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
extendedSecret[0] &= 248;
|
|
1031
|
-
extendedSecret[31] &= 63;
|
|
1032
|
-
extendedSecret[31] |= 64;
|
|
1033
|
-
}
|
|
1034
|
-
privKey = Buffer.from(extendedSecret);
|
|
1035
|
-
}
|
|
1036
|
-
super(privKey);
|
|
1111
|
+
// src/message-signing/check-signature.ts
|
|
1112
|
+
var checkSignature = (data, { key, signature }) => {
|
|
1113
|
+
const builder = CoseSign1.fromCbor(signature);
|
|
1114
|
+
if (builder.getPayload() === null) {
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1118
|
+
return false;
|
|
1037
1119
|
}
|
|
1120
|
+
return builder.verifySignature({
|
|
1121
|
+
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1122
|
+
});
|
|
1038
1123
|
};
|
|
1039
1124
|
|
|
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
1125
|
// ../../node_modules/nanoid/index.js
|
|
1123
1126
|
import crypto from "crypto";
|
|
1124
1127
|
var POOL_SIZE_MULTIPLIER = 128;
|
|
@@ -1156,8 +1159,20 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
|
1156
1159
|
};
|
|
1157
1160
|
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
1158
1161
|
|
|
1159
|
-
// src/message-signing/
|
|
1162
|
+
// src/message-signing/generate-nonce.ts
|
|
1160
1163
|
import { stringToHex } from "@meshsdk/common";
|
|
1164
|
+
var generateNonce = (label = "", length = 32) => {
|
|
1165
|
+
if (length <= 0 || length > 2048) {
|
|
1166
|
+
throw new Error("Length must be bewteen 1 and 2048");
|
|
1167
|
+
}
|
|
1168
|
+
const randomString = customAlphabet(
|
|
1169
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1170
|
+
);
|
|
1171
|
+
const payload = randomString(length);
|
|
1172
|
+
return stringToHex(`${label}${payload}`);
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
// src/message-signing/sign-data.ts
|
|
1161
1176
|
var signData = (data, signer) => {
|
|
1162
1177
|
const payload = Buffer.from(data, "hex");
|
|
1163
1178
|
const publicKey = signer.key.toPublicKey().toBytes();
|
|
@@ -1177,28 +1192,6 @@ var signData = (data, signer) => {
|
|
|
1177
1192
|
signature: coseSignature
|
|
1178
1193
|
};
|
|
1179
1194
|
};
|
|
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
1195
|
|
|
1203
1196
|
// src/resolvers/index.ts
|
|
1204
1197
|
import { Cardano as Cardano2 } from "@cardano-sdk/core";
|
|
@@ -1251,7 +1244,7 @@ var buildBip32PrivateKey = (entropy, password = "") => {
|
|
|
1251
1244
|
PBKDF2_KEY_SIZE,
|
|
1252
1245
|
PBKDF2_DIGEST_ALGORITHM
|
|
1253
1246
|
);
|
|
1254
|
-
return
|
|
1247
|
+
return Bip32PrivateKey2.fromBytes(clampScalar(xprv));
|
|
1255
1248
|
};
|
|
1256
1249
|
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
1257
1250
|
const cred = {
|
|
@@ -1262,19 +1255,18 @@ var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
|
1262
1255
|
};
|
|
1263
1256
|
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
1264
1257
|
if (typeof entropy === "string") {
|
|
1265
|
-
const rootKey = new
|
|
1258
|
+
const rootKey = new Bip32PrivateKey3(Buffer.from(entropy, "hex"));
|
|
1266
1259
|
const accountKey = rootKey.derive(HARDENED_KEY_START + 1852).derive(HARDENED_KEY_START + 1815).derive(HARDENED_KEY_START + accountIndex);
|
|
1267
1260
|
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
1268
1261
|
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
1269
|
-
|
|
1262
|
+
const dRepKey = accountKey.derive(3).derive(keyIndex).toPrivateKey();
|
|
1263
|
+
return { paymentKey, stakeKey, dRepKey };
|
|
1270
1264
|
} else {
|
|
1271
|
-
const paymentKey =
|
|
1272
|
-
Buffer.from(entropy[0], "hex")
|
|
1273
|
-
false
|
|
1265
|
+
const paymentKey = PrivateKey.fromSecretKey(
|
|
1266
|
+
Buffer.from(entropy[0], "hex")
|
|
1274
1267
|
);
|
|
1275
|
-
const stakeKey =
|
|
1276
|
-
Buffer.from(entropy[1], "hex")
|
|
1277
|
-
false
|
|
1268
|
+
const stakeKey = PrivateKey.fromSecretKey(
|
|
1269
|
+
Buffer.from(entropy[1], "hex")
|
|
1278
1270
|
);
|
|
1279
1271
|
return { paymentKey, stakeKey };
|
|
1280
1272
|
}
|
|
@@ -1717,8 +1709,8 @@ var resolvePlutusScriptHash = (bech32) => {
|
|
|
1717
1709
|
throw new Error(`An error occurred during resolveScriptHash: ${error}.`);
|
|
1718
1710
|
}
|
|
1719
1711
|
};
|
|
1720
|
-
var resolvePoolId = (
|
|
1721
|
-
return Ed25519KeyHashHex2(
|
|
1712
|
+
var resolvePoolId = (hash) => {
|
|
1713
|
+
return Ed25519KeyHashHex2(hash).toString();
|
|
1722
1714
|
};
|
|
1723
1715
|
var resolvePrivateKey = (words) => {
|
|
1724
1716
|
return "not implemented";
|
|
@@ -1752,8 +1744,8 @@ var resolveStakeKeyHash = (bech32) => {
|
|
|
1752
1744
|
};
|
|
1753
1745
|
var resolveTxHash = (txHex) => {
|
|
1754
1746
|
const txBody = deserializeTx(txHex).body();
|
|
1755
|
-
const
|
|
1756
|
-
return Cardano2.TransactionId.fromHexBlob(HexBlob4.fromBytes(
|
|
1747
|
+
const hash = blake2b3(blake2b3.BYTES).update(hexToBytes(txBody.toCbor())).digest();
|
|
1748
|
+
return Cardano2.TransactionId.fromHexBlob(HexBlob4.fromBytes(hash));
|
|
1757
1749
|
};
|
|
1758
1750
|
|
|
1759
1751
|
// src/serializer/index.ts
|
|
@@ -1826,7 +1818,7 @@ var CardanoSDKSerializer = class {
|
|
|
1826
1818
|
serializeRewardAddress(stakeKeyHash, isScriptHash, network_id) {
|
|
1827
1819
|
throw new Error("Method not implemented.");
|
|
1828
1820
|
}
|
|
1829
|
-
serializePoolId(
|
|
1821
|
+
serializePoolId(hash) {
|
|
1830
1822
|
throw new Error("Method not implemented.");
|
|
1831
1823
|
}
|
|
1832
1824
|
serializeAddress(address, networkId) {
|
|
@@ -1953,9 +1945,8 @@ var CardanoSDKSerializer = class {
|
|
|
1953
1945
|
if (keyHex.length === 68 && keyHex.substring(0, 4) === "5820") {
|
|
1954
1946
|
keyHex = keyHex.substring(4);
|
|
1955
1947
|
}
|
|
1956
|
-
const cardanoSigner =
|
|
1957
|
-
Buffer.from(keyHex, "hex")
|
|
1958
|
-
false
|
|
1948
|
+
const cardanoSigner = PrivateKey.fromSecretKey(
|
|
1949
|
+
Buffer.from(keyHex, "hex")
|
|
1959
1950
|
);
|
|
1960
1951
|
const signature = cardanoSigner.sign(
|
|
1961
1952
|
Buffer.from(cardanoTx.getId(), "hex")
|
|
@@ -2542,7 +2533,7 @@ export {
|
|
|
2542
2533
|
AssetId,
|
|
2543
2534
|
AssetName,
|
|
2544
2535
|
BaseAddress,
|
|
2545
|
-
|
|
2536
|
+
Bip32PrivateKey2 as Bip32PrivateKey,
|
|
2546
2537
|
Bip32PrivateKeyHex2 as Bip32PrivateKeyHex,
|
|
2547
2538
|
Cardano4 as Cardano,
|
|
2548
2539
|
CardanoSDK,
|
|
@@ -2553,11 +2544,13 @@ export {
|
|
|
2553
2544
|
Certificate,
|
|
2554
2545
|
CertificateType,
|
|
2555
2546
|
ConstrPlutusData,
|
|
2547
|
+
CoseSign1,
|
|
2556
2548
|
CostModel,
|
|
2557
2549
|
Costmdls,
|
|
2558
2550
|
Credential,
|
|
2559
2551
|
CredentialType,
|
|
2560
2552
|
Crypto3 as Crypto,
|
|
2553
|
+
DRep,
|
|
2561
2554
|
DRepID,
|
|
2562
2555
|
Datum,
|
|
2563
2556
|
DatumHash,
|
|
@@ -2604,13 +2597,15 @@ export {
|
|
|
2604
2597
|
ScriptPubkey,
|
|
2605
2598
|
Serialization5 as Serialization,
|
|
2606
2599
|
Slot,
|
|
2600
|
+
StakeCredentialStatus,
|
|
2607
2601
|
StakeDelegation,
|
|
2608
2602
|
StakeRegistration,
|
|
2609
|
-
|
|
2603
|
+
Bip32PrivateKey3 as StricaBip32PrivateKey,
|
|
2610
2604
|
Bip32PublicKey as StricaBip32PublicKey,
|
|
2611
|
-
|
|
2605
|
+
Decoder as StricaDecoder,
|
|
2606
|
+
Encoder as StricaEncoder,
|
|
2612
2607
|
PrivateKey as StricaPrivateKey,
|
|
2613
|
-
|
|
2608
|
+
PublicKey as StricaPublicKey,
|
|
2614
2609
|
Transaction,
|
|
2615
2610
|
TransactionBody,
|
|
2616
2611
|
TransactionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/core-cst",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"@cardano-sdk/core": "^0.35.4",
|
|
39
39
|
"@cardano-sdk/crypto": "^0.1.28",
|
|
40
40
|
"@cardano-sdk/util": "^0.15.4",
|
|
41
|
+
"@harmoniclabs/cbor": "^1.3.0",
|
|
42
|
+
"@harmoniclabs/plutus-data": "^1.2.4",
|
|
43
|
+
"@harmoniclabs/uplc": "^1.2.4",
|
|
41
44
|
"@meshsdk/common": "*",
|
|
42
45
|
"@stricahq/bip32ed25519": "^1.1.0",
|
|
43
46
|
"@stricahq/cbors": "^1.0.0",
|