aws-sdk#KMS TypeScript Examples
The following examples show how to use
aws-sdk#KMS.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: aws-kms-utils.ts From ethers-aws-kms-signer with MIT License | 7 votes |
/* eslint-enable func-names */
export async function sign(digest: Buffer, kmsCredentials: AwsKmsSignerCredentials) {
const kms = new KMS(kmsCredentials);
const params: KMS.SignRequest = {
// key id or 'Alias/<alias>'
KeyId: kmsCredentials.keyId,
Message: digest,
// 'ECDSA_SHA_256' is the one compatible with ECC_SECG_P256K1.
SigningAlgorithm: "ECDSA_SHA_256",
MessageType: "DIGEST",
};
const res = await kms.sign(params).promise();
return res;
}
Example #2
Source File: aws-kms-utils.ts From ethers-aws-kms-signer with MIT License | 6 votes |
export async function getPublicKey(kmsCredentials: AwsKmsSignerCredentials) {
const kms = new KMS(kmsCredentials);
return kms
.getPublicKey({
KeyId: kmsCredentials.keyId,
})
.promise();
}
Example #3
Source File: kms.ts From hardhat-kms-signer with MIT License | 6 votes |
getEthAddressFromPublicKey = (
publicKey: KMS.PublicKeyType
): string => {
const res = EcdsaPubKey.decode(publicKey as string, "der");
let pubKeyBuffer: Buffer = res.pubKey.data;
pubKeyBuffer = pubKeyBuffer.slice(1, pubKeyBuffer.length);
const address = EthUtil.keccak256(pubKeyBuffer);
const EthAddr = "0x" + address.slice(-20).toString("hex");
return EthAddr;
}
Example #4
Source File: kms.ts From hardhat-kms-signer with MIT License | 6 votes |
getEthAddressFromKMS = async (
keyId: KMS.GetPublicKeyRequest["KeyId"]
) => {
const KMSKey = await getPublicKey(keyId);
if (!KMSKey.PublicKey) {
throw new Error("Failed to get PublicKey from KMS");
}
return getEthAddressFromPublicKey(KMSKey.PublicKey);
}
Example #5
Source File: crypto.ts From cognito-local with MIT License | 5 votes |
config?: KMSConfig & AWS.KMS.ClientConfiguration;
Example #6
Source File: kms.ts From hardhat-kms-signer with MIT License | 5 votes |
kms = new KMS()
Example #7
Source File: kms.ts From hardhat-kms-signer with MIT License | 5 votes |
getPublicKey = (KeyId: KMS.GetPublicKeyRequest["KeyId"]) =>
kms.getPublicKey({ KeyId }).promise()