|
| 1 | +/** |
| 2 | + * @file starkcurve.h |
| 3 | + * @author Cypherock X1 Team |
| 4 | + * @brief Constants for Starknet curve. |
| 5 | + * @copyright Copyright (c) 2023 HODL TECH PTE LTD |
| 6 | + * <br/> You may obtain a copy of license at <a href="https://mitcc.org/" |
| 7 | + *target=_blank>https://mitcc.org/</a> |
| 8 | + * |
| 9 | + ****************************************************************************** |
| 10 | + * @attention |
| 11 | + * |
| 12 | + * (c) Copyright 2023 by HODL TECH PTE LTD |
| 13 | + * |
| 14 | + * Permission is hereby granted, free of charge, to any person obtaining |
| 15 | + * a copy of this software and associated documentation files (the |
| 16 | + * "Software"), to deal in the Software without restriction, including |
| 17 | + * without limitation the rights to use, copy, modify, merge, publish, |
| 18 | + * distribute, sublicense, and/or sell copies of the Software, and to |
| 19 | + * permit persons to whom the Software is furnished to do so, subject |
| 20 | + * to the following conditions: |
| 21 | + * |
| 22 | + * The above copyright notice and this permission notice shall be |
| 23 | + * included in all copies or substantial portions of the Software. |
| 24 | + * |
| 25 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 26 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 27 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 28 | + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 29 | + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 30 | + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 31 | + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 32 | + * |
| 33 | + * |
| 34 | + * "Commons Clause" License Condition v1.0 |
| 35 | + * |
| 36 | + * The Software is provided to you by the Licensor under the License, |
| 37 | + * as defined below, subject to the following condition. |
| 38 | + * |
| 39 | + * Without limiting other conditions in the License, the grant of |
| 40 | + * rights under the License will not include, and the License does not |
| 41 | + * grant to you, the right to Sell the Software. |
| 42 | + * |
| 43 | + * For purposes of the foregoing, "Sell" means practicing any or all |
| 44 | + * of the rights granted to you under the License to provide to third |
| 45 | + * parties, for a fee or other consideration (including without |
| 46 | + * limitation fees for hosting or consulting/ support services related |
| 47 | + * to the Software), a product or service whose value derives, entirely |
| 48 | + * or substantially, from the functionality of the Software. Any license |
| 49 | + * notice or attribution required by the License must also include |
| 50 | + * this Commons Clause License Condition notice. |
| 51 | + * |
| 52 | + * Software: All X1Wallet associated files. |
| 53 | + * License: MIT |
| 54 | + * Licensor: HODL TECH PTE LTD |
| 55 | + * |
| 56 | + ****************************************************************************** |
| 57 | + */ |
| 58 | + |
| 59 | +/***************************************************************************** |
| 60 | + * INCLUDES |
| 61 | + *****************************************************************************/ |
| 62 | + |
| 63 | +/***************************************************************************** |
| 64 | + * EXTERN VARIABLES |
| 65 | + *****************************************************************************/ |
| 66 | + |
| 67 | +/***************************************************************************** |
| 68 | + * MACROS AND DEFINES |
| 69 | + *****************************************************************************/ |
| 70 | +#define SIZE_HEX 16 |
| 71 | + |
| 72 | +// Starknet curve constants |
| 73 | +#define STARKNET_CURVE_PRIME \ |
| 74 | + "0800000000000011000000000000000000000000000000000000000000000001" |
| 75 | +#define STARKNET_CURVE_GX \ |
| 76 | + "01EF15C18599971B7BECED415A40F0C7DEACFD9B0D1819E03D723D8BC943CFCA" |
| 77 | +#define STARKNET_CURVE_GY \ |
| 78 | + "005668060AA49730B7BE4801DF46EC62DE53ECD11ABE43A32873000C36E8DC1F" |
| 79 | +#define STARKNET_CURVE_ORDER \ |
| 80 | + "0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f" |
| 81 | +#define STARKNET_CURVE_ORDER_HALF \ |
| 82 | + "04000000000000087fffffffffffffffdbc08936e573d9190f335120d6e32697" |
| 83 | +#define STARKNET_CURVE_A \ |
| 84 | + "0000000000000000000000000000000000000000000000000000000000000001" |
| 85 | +#define STARKNET_CURVE_B \ |
| 86 | + "06f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e89" |
| 87 | + |
| 88 | +// starknet pedersen points |
| 89 | +// Ref: https://docs.starkware.co/starkex/crypto/pedersen-hash-function.html |
| 90 | +#define STARKNET_PEDERSEN_POINT_0_X \ |
| 91 | + "049EE3EBA8C1600700EE1B87EB599F16716B0B1022947733551FDE4050CA6804" |
| 92 | +#define STARKNET_PEDERSEN_POINT_0_Y \ |
| 93 | + "03CA0CFE4B3BC6DDF346D49D06EA0ED34E621062C0E056C1D0405D266E10268A" |
| 94 | +#define STARKNET_PEDERSEN_POINT_1_X \ |
| 95 | + "0234287DCBAFFE7F969C748655FCA9E58FA8120B6D56EB0C1080D17957EBE47B" |
| 96 | +#define STARKNET_PEDERSEN_POINT_1_Y \ |
| 97 | + "03B056F100F96FB21E889527D41F4E39940135DD7A6C94CC6ED0268EE89E5615" |
| 98 | +#define STARKNET_PEDERSEN_POINT_2_X \ |
| 99 | + "04FA56F376C83DB33F9DAB2656558F3399099EC1DE5E3018B7A6932DBA8AA378" |
| 100 | +#define STARKNET_PEDERSEN_POINT_2_Y \ |
| 101 | + "03FA0984C931C9E38113E0C0E47E4401562761F92A7A23B45168F4E80FF5B54D" |
| 102 | +#define STARKNET_PEDERSEN_POINT_3_X \ |
| 103 | + "04BA4CC166BE8DEC764910F75B45F74B40C690C74709E90F3AA372F0BD2D6997" |
| 104 | +#define STARKNET_PEDERSEN_POINT_3_Y \ |
| 105 | + "040301CF5C1751F4B971E46C4EDE85FCAC5C59A5CE5AE7C48151F27B24B219C" |
| 106 | +#define STARKNET_PEDERSEN_POINT_4_X \ |
| 107 | + "054302DCB0E6CC1C6E44CCA8F61A63BB2CA65048D53FB325D36FF12C49A58202" |
| 108 | +#define STARKNET_PEDERSEN_POINT_4_Y \ |
| 109 | + "01B77B3E37D13504B348046268D8AE25CE98AD783C25561A879DCC77E99C2426" |
| 110 | + |
| 111 | +// starknet limit |
| 112 | +#define STARKNET_LIMIT \ |
| 113 | + "F80000000000020EFFFFFFFFFFFFFFF738A13B4B920E9411AE6DA5F40B0358B1" |
0 commit comments