sm2_blind.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the License); you may
  5. * not use this file except in compliance with the License.
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. */
  9. #ifndef GMSSL_SM2_BLIND_H
  10. #define GMSSL_SM2_BLIND_H
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14. #include <assert.h>
  15. #include <gmssl/sm2.h>
  16. #include <gmssl/mem.h>
  17. #include <gmssl/asn1.h>
  18. #include <gmssl/error.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct {
  23. SM3_CTX sm3_ctx;
  24. SM2_KEY public_key;
  25. uint8_t blind_factor_a[32];
  26. uint8_t blind_factor_b[32];
  27. uint8_t sig_r[32];
  28. } SM2_BLIND_SIGN_CTX;
  29. #define SM2_BLIND_SIGN_MAX_COMMITLEN 65
  30. int sm2_blind_sign_commit(SM2_Fn k, uint8_t *commit, size_t *commitlen);
  31. int sm2_blind_sign_init(SM2_BLIND_SIGN_CTX *ctx, const SM2_KEY *public_key, const char *id, size_t idlen);
  32. int sm2_blind_sign_update(SM2_BLIND_SIGN_CTX *ctx, const uint8_t *data, size_t datalen);
  33. int sm2_blind_sign_finish(SM2_BLIND_SIGN_CTX *ctx, const uint8_t *commit, size_t commitlen, uint8_t blinded_sig_r[32]);
  34. int sm2_blind_sign(const SM2_KEY *key, const SM2_Fn k, const uint8_t blinded_sig_r[32], uint8_t blinded_sig_s[32]);
  35. int sm2_blind_sign_unblind(SM2_BLIND_SIGN_CTX *ctx, const uint8_t blinded_sig_s[32], uint8_t *sig, size_t *siglen);
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif