secp256k1.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 =*/{0x1ffffc2f, 0x1ffffff7, 0x1fffffff, 0x1fffffff,
  26. 0x1fffffff, 0x1fffffff, 0x1fffffff, 0x1fffffff,
  27. 0xffffff}},
  28. /* G */
  29. {/*.x =*/{/*.val =*/{0x16f81798, 0x0f940ad8, 0x138a3656, 0x17f9b65b,
  30. 0x10b07029, 0x114ae743, 0x0eb15681, 0x0fdf3b97,
  31. 0x79be66}},
  32. /*.y =*/{/*.val =*/{0x1b10d4b8, 0x023e847f, 0x01550667, 0x0f68914d,
  33. 0x108a8fd1, 0x1dfe0708, 0x11957693, 0x0ee4d478,
  34. 0x483ada}}},
  35. /* order */
  36. {/*.val =*/{0x10364141, 0x1e92f466, 0x12280eef, 0x1db9cd5e, 0x1fffebaa,
  37. 0x1fffffff, 0x1fffffff, 0x1fffffff, 0xffffff}},
  38. /* order_half */
  39. {/*.val =*/{0x081b20a0, 0x1f497a33, 0x09140777, 0x0edce6af, 0x1ffff5d5,
  40. 0x1fffffff, 0x1fffffff, 0x1fffffff, 0x7fffff}},
  41. /* a */ 0,
  42. /* b */ {/*.val =*/{7}}
  43. #if USE_PRECOMPUTED_CP
  44. ,
  45. /* cp */
  46. {
  47. #include "secp256k1.table"
  48. }
  49. #endif
  50. };
  51. const curve_info secp256k1_info = {
  52. .bip32_name = "Bitcoin seed",
  53. .params = &secp256k1,
  54. .hasher_base58 = HASHER_SHA2D,
  55. .hasher_sign = HASHER_SHA2D,
  56. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  57. .hasher_script = HASHER_SHA2,
  58. };
  59. const curve_info secp256k1_decred_info = {
  60. .bip32_name = "Bitcoin seed",
  61. .params = &secp256k1,
  62. .hasher_base58 = HASHER_BLAKED,
  63. .hasher_sign = HASHER_BLAKE,
  64. .hasher_pubkey = HASHER_BLAKE_RIPEMD,
  65. .hasher_script = HASHER_BLAKE,
  66. };
  67. const curve_info secp256k1_groestl_info = {
  68. .bip32_name = "Bitcoin seed",
  69. .params = &secp256k1,
  70. .hasher_base58 = HASHER_GROESTLD_TRUNC,
  71. .hasher_sign = HASHER_SHA2,
  72. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  73. .hasher_script = HASHER_SHA2,
  74. };
  75. const curve_info secp256k1_smart_info = {
  76. .bip32_name = "Bitcoin seed",
  77. .params = &secp256k1,
  78. #if USE_KECCAK
  79. .hasher_base58 = HASHER_SHA3K,
  80. #else
  81. .hasher_base58 = HASHER_SHA3,
  82. #endif
  83. .hasher_sign = HASHER_SHA2,
  84. .hasher_pubkey = HASHER_SHA2_RIPEMD,
  85. .hasher_script = HASHER_SHA2,
  86. };