Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/starkware/crypto/ffi/crypto_lib/crypto_lib.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package crypto_lib

import "encoding/hex"
import (
"encoding/hex"
"fmt"
"math/big"
"unsafe"
)

/*

#cgo CFLAGS: -I.
Expand All @@ -15,8 +17,6 @@ import (

*/
import "C"
import "unsafe"


const curveOrder = "800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f"

Expand All @@ -40,8 +40,8 @@ func reverseHexEndianRepresentation(s string) string {
rns := []rune(s)
for i, j := 0, len(rns)-2; i < j; i, j = i+2, j-2 {
rns[i], rns[j] = rns[j], rns[i]
rns[i+1], rns[j+1] = rns[j+1], rns[i+1]
}
rns[i+1], rns[j+1] = rns[j+1], rns[i+1]
}
return string(rns)
}

Expand All @@ -56,7 +56,7 @@ func padHexString(s string) string {
/*
Computes the StarkWare version of the Pedersen hash of x and y.
Full specification of the hash function can be found here:
https://docs.starkware.co/starkex-docs/crypto/pedersen-hash-function
https://docs.starkware.co/starkex/pedersen-hash-function.html
*/
func Hash(input1, input2 string) string {
input1_dec, _ := hex.DecodeString(reverseHexEndianRepresentation(input1))
Expand Down
2 changes: 1 addition & 1 deletion src/starkware/crypto/ffi/js/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const curveOrder = new BN('800000000000010ffffffffffffffffb781126dcae7b2321e66a2
/*
Computes the StarkWare version of the Pedersen hash of x and y.
Full specification of the hash function can be found here:
https://docs.starkware.co/starkex-docs/crypto/pedersen-hash-function
https://docs.starkware.co/starkex/pedersen-hash-function.html
*/
function pedersen(x, y) {
const x_buf = BigIntBuffer.toBufferLE(x, 32);
Expand Down