#pragma once #include #include #include __device__ __forceinline__ void expand_key(unsigned char* expanded, const unsigned char* secret) { struct sha512_state s; sha512_init(&s); sha512_final(&s, secret, 32); sha512_get(&s, expanded, 0, 64); ed25519_prepare(expanded); } __device__ __forceinline__ void pp(unsigned char* packed, const struct ed25519_pt* p) { unsigned char x[F25519_SIZE], y[F25519_SIZE]; ed25519_unproject(x, y, p); ed25519_pack(packed, x, y); } __device__ __forceinline__ void sm_pack(unsigned char* r, const unsigned char* k) { struct ed25519_pt p; ed25519_smult(&p, &ed25519_base, k); pp(r, &p); } __device__ __forceinline__ void edsign_sec_to_pub(unsigned char* pub, const unsigned char* secret) { unsigned char expanded[64]; expand_key(expanded, secret); sm_pack(pub, expanded); }