secp256k1.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * Copyright (c) 2013-2014 Tomas Dzetkulic
  3. * Copyright (c) 2013-2014 Pavol Rusnak
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included
  13. * in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  16. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
  19. * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. * OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "secp256k1.h"
  24. const ecdsa_curve secp256k1 = {
  25. /* .prime */ {/*.val =*/{
  26. 0x1ffffc2f,
  27. 0x1ffffff7,
  28. 0x1fffffff,
  29. 0x1fffffff,
  30. 0x1fffffff,
  31. 0x1fffffff,
  32. 0x1fffffff,
  33. 0x1fffffff,
  34. 0xffffff}},
  35. /* G */
  36. {/*.x =*/{/*.val =*/{
  37. 0x16f81798,
  38. 0x0f940ad8,
  39. 0x138a3656,
  40. 0x17f9b65b,
  41. 0x10b07029,
  42. 0x114ae743,
  43. 0x0eb15681,
  44. 0x0fdf3b97,
  45. 0x79be66}},
  46. /*.y =*/{/*.val =*/{
  47. 0x1b10d4b8,
  48. 0x023e847f,
  49. 0x01550667,
  50. 0x0f68914d,
  51. 0x108a8fd1,
  52. 0x1dfe0708,
  53. 0x11957693,
  54. 0x0ee4d478,
  55. 0x483ada}}},
  56. /* order */
  57. {/*.val =*/{
  58. 0x10364141,
  59. 0x1e92f466,
  60. 0x12280eef,
  61. 0x1db9cd5e,
  62. 0x1fffebaa,
  63. 0x1fffffff,
  64. 0x1fffffff,
  65. 0x1fffffff,
  66. 0xffffff}},
  67. /* order_half */
  68. {/*.val =*/{
  69. 0x081b20a0,
  70. 0x1f497a33,
  71. 0x09140777,
  72. 0x0edce6af,
  73. 0x1ffff5d5,
  74. 0x1fffffff,
  75. 0x1fffffff,
  76. 0x1fffffff,
  77. 0x7fffff}},
  78. /* a */ 0,
  79. /* b */ {/*.val =*/{7}}
  80. #if USE_PRECOMPUTED_CP
  81. ,
  82. /* cp */
  83. {
  84. #include "secp256k1.table"
  85. }
  86. #endif
  87. };
  88. const curve_info secp256k1_info = {
  89. .bip32_name = "Bitcoin seed",
  90. .params = &secp256k1,
  91. .hasher_base58 = HASHER_SHA2D,
  92. .hasher_sign = HASHER_SHA2D,
  93. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  94. .hasher_script = HASHER_SHA2,
  95. };
  96. const curve_info secp256k1_decred_info = {
  97. .bip32_name = "Bitcoin seed",
  98. .params = &secp256k1,
  99. .hasher_base58 = HASHER_BLAKED,
  100. .hasher_sign = HASHER_BLAKE,
  101. .hasher_pubkey = HASHER_BLAKE_RIPEMD,
  102. .hasher_script = HASHER_BLAKE,
  103. };
  104. const curve_info secp256k1_groestl_info = {
  105. .bip32_name = "Bitcoin seed",
  106. .params = &secp256k1,
  107. .hasher_base58 = HASHER_GROESTLD_TRUNC,
  108. .hasher_sign = HASHER_SHA2,
  109. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  110. .hasher_script = HASHER_SHA2,
  111. };
  112. const curve_info secp256k1_smart_info = {
  113. .bip32_name = "Bitcoin seed",
  114. .params = &secp256k1,
  115. #if USE_KECCAK
  116. .hasher_base58 = HASHER_SHA3K,
  117. #else
  118. .hasher_base58 = HASHER_SHA3,
  119. #endif
  120. .hasher_sign = HASHER_SHA2,
  121. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  122. .hasher_script = HASHER_SHA2,
  123. };