Crypto 유틸리티
이는 CDR SDK 내부적으로 사용되는 저수준 암호화 함수입니다. 일반적으로 커스텀 복호화 흐름을 빌드하는 경우가 아니라면 이를 직접 호출할 필요가 없습니다.모든 crypto 함수는 먼저
initWasm()을 통해 WASM이 초기화되어야 합니다.현재 Aeneid 릴리즈에는 검증자 attestation을 예상 enclave 측정값 및 security
version 값과 비교하여 확인하기 위한
verifyAttestation()을 포함한 SGX
attestation 검증 유틸리티도 포함되어 있습니다.함수
- initWasm
- tdh2Encrypt
- tdh2Verify
- tdh2Combine
- decryptPartial
- parseSgxQuote
- verifyAttestation
- uuidToLabel
initWasm
모든 TDH2 암호화 연산에 필요한 WebAssembly 모듈을 초기화합니다. 다른 crypto 함수보다 먼저 한 번 호출되어야 합니다.| Function | Type |
|---|---|
initWasm | () => Promise<void> |
Example
tdh2Encrypt
DKG global public key에 대해 TDH2 threshold encryption을 사용하여 평문을 암호화합니다.| Function | Type |
|---|---|
tdh2Encrypt | (params: TDH2EncryptParams) => Promise<TDH2Ciphertext> |
params.plaintext:Uint8Array- 암호화할 데이터params.globalPubKey:Uint8Array- DKG global public key (Ed25519 접두사 포함 34 bytes)params.label:Uint8Array- 특정 볼트에 ciphertext를 바인딩하는 32바이트 label
Example
TDH2Ciphertext
tdh2Verify
복호화 없이 TDH2 ciphertext를 검증합니다. 무결성 검사에 유용합니다.| Function | Type |
|---|---|
tdh2Verify | (params: TDH2VerifyParams) => Promise<boolean> |
params.ciphertext:Uint8Array- 원시 ciphertext 바이트params.globalPubKey:Uint8Array- DKG global public keyparams.label:Uint8Array- 암호화 중에 사용된 32바이트 label
Example
tdh2Combine
threshold 부분 복호화를 결합하여 원본 평문을 복구합니다.| Function | Type |
|---|---|
tdh2Combine | (params: TDH2CombineParams) => Promise<Uint8Array> |
params.ciphertext:TDH2Ciphertext- 암호화된 데이터 ({ raw, label })params.partials:DecryptedPartial[]- 복호화된 부분 복호화 배열 (>= threshold가 있어야 함)params.globalPubKey:Uint8Array- DKG global public keyparams.label:Uint8Array- 32바이트 labelparams.threshold:number- 필요한 부분 복호화의 최소 개수
Example
DecryptedPartial
decryptPartial
ECIES (ECDH + HKDF + AES-256-GCM)를 사용하여 검증자로부터의 단일 암호화된 부분 복호화를 복호화합니다.| Function | Type |
|---|---|
decryptPartial | (params: DecryptPartialParams) => Promise<Uint8Array> |
params.encryptedPartial:Uint8Array- 암호화된 부분 복호화 (nonce || ciphertext || tag)params.ephemeralPubKey:Uint8Array- 검증자의 일회용 공개 키 (65 bytes, 압축되지 않은 secp256k1)params.recipientPrivKey:Uint8Array- 본인의 일회용 개인 키 (32 bytes, secp256k1)
Example
- ECDH:
sharedPoint = secp256k1(recipientPrivKey, ephemeralPubKey) - HKDF-SHA256:
aesKey = hkdf(sha256, sharedSecret, info="dkg-tdh2-partial", 32) - AES-256-GCM: 암호화된 부분 복호화의 12바이트 nonce로 복호화
verifyAttestation
검증자의 SGX attestation 문서를 예상되는 enclave 측정값 및 최소 security version 검사와 비교하여 검증합니다. 애플리케이션에서 명시적인MRENCLAVE,
MRSIGNER, SVN 신뢰 검사를 원할 때
observer.getValidatorAttestations()에서 반환된 데이터와 함께 사용하세요.
매개변수:
report:Uint8Array- 원시 SGX DCAP Quote v3 바이트config.expectedMrEnclave(선택):`0x${string}`- 예상되는 enclave 측정값config.expectedMrSigner(선택):`0x${string}`- 예상되는 signer 측정값config.minSecurityVersion(선택):number- 허용되는 최소 ISV SVN
Example
verifyAttestation()은 클라이언트 측 필드 검사를 수행합니다. quote 서명 체인
자체는 온체인에서 검증되며, 이 헬퍼는 SDK 사용자를 위한 추가적인 허용 목록 /
정책 검사입니다.parseSgxQuote
정책을 적용하지 않고 SGX DCAP Quote v3에서 주요 필드를 파싱합니다.| Function | Type |
|---|---|
parseSgxQuote | (report: Uint8Array) => { mrEnclave, mrSigner, securityVersion } |
report:Uint8Array- 원시 SGX DCAP Quote v3 바이트
mrEnclave:`0x${string}`- 파싱된 enclave 측정값mrSigner:`0x${string}`- 파싱된 signer 측정값securityVersion:number- 파싱된 ISV SVN
Example
uuidToLabel
볼트 UUID로부터 결정적인 32바이트 label을 파생합니다. 특정 볼트에 ciphertext를 바인딩하는 데 사용됩니다.| Function | Type |
|---|---|
uuidToLabel | (uuid: number) => Uint8Array |
uuid:number- 볼트 UUID (uint32)
Uint8Array를 반환합니다.
Example