Upgrade blst & remove sha256 patch (#85)
This commit is contained in:
parent
8907fbcfe2
commit
0a18868475
|
@ -1,4 +1,3 @@
|
||||||
[submodule "blst"]
|
[submodule "blst"]
|
||||||
path = blst
|
path = blst
|
||||||
url = https://github.com/supranational/blst
|
url = https://github.com/supranational/blst
|
||||||
ignore = dirty # because we apply a patch
|
|
||||||
|
|
|
@ -27,11 +27,7 @@ CLANG_FLAGS += -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB)
|
||||||
TARGETS=ckzg.c ../../src/c_kzg_4844.c ../../blst/$(BLST_OBJ)
|
TARGETS=ckzg.c ../../src/c_kzg_4844.c ../../blst/$(BLST_OBJ)
|
||||||
|
|
||||||
.blst:
|
.blst:
|
||||||
cd ../../blst &&\
|
cd ../../blst && $(BLST_BUILDSCRIPT)
|
||||||
git apply ../blst_sha.patch &&\
|
|
||||||
$(BLST_BUILDSCRIPT) &&\
|
|
||||||
git apply -R ../blst_sha.patch &&\
|
|
||||||
cd ../bindings/csharp
|
|
||||||
|
|
||||||
.ckzg:
|
.ckzg:
|
||||||
$(CLANG_EXECUTABLE) -O -Wall -shared $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(CKZG_LIBRARY_PATH) $(TARGETS)
|
$(CLANG_EXECUTABLE) -O -Wall -shared $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(CKZG_LIBRARY_PATH) $(TARGETS)
|
||||||
|
|
2
blst
2
blst
|
@ -1 +1 @@
|
||||||
Subproject commit 6382d67c72119d563975892ed49ba32e92d3d0da
|
Subproject commit ca03e11a3ff24d818ae390a1e7f435f15bf72aee
|
|
@ -1,31 +0,0 @@
|
||||||
diff --git a/src/sha256.h b/src/sha256.h
|
|
||||||
index 77ddb6d..67ccf7a 100644
|
|
||||||
--- a/src/sha256.h
|
|
||||||
+++ b/src/sha256.h
|
|
||||||
@@ -49,7 +49,7 @@ static void sha256_init_h(unsigned int h[8])
|
|
||||||
h[7] = 0x5be0cd19U;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void sha256_init(SHA256_CTX *ctx)
|
|
||||||
+void sha256_init(SHA256_CTX *ctx)
|
|
||||||
{
|
|
||||||
sha256_init_h(ctx->h);
|
|
||||||
ctx->N = 0;
|
|
||||||
@@ -57,7 +57,7 @@ static void sha256_init(SHA256_CTX *ctx)
|
|
||||||
ctx->off = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void sha256_update(SHA256_CTX *ctx, const void *_inp, size_t len)
|
|
||||||
+void sha256_update(SHA256_CTX *ctx, const void *_inp, size_t len)
|
|
||||||
{
|
|
||||||
size_t n;
|
|
||||||
const unsigned char *inp = _inp;
|
|
||||||
@@ -116,7 +116,7 @@ static void sha256_emit(unsigned char md[32], const unsigned int h[8])
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-static void sha256_final(unsigned char md[32], SHA256_CTX *ctx)
|
|
||||||
+void sha256_final(unsigned char md[32], SHA256_CTX *ctx)
|
|
||||||
{
|
|
||||||
unsigned long long bits = ctx->N * 8;
|
|
||||||
size_t n = ctx->off;
|
|
|
@ -16,11 +16,8 @@ all: c_kzg_4844.o lib
|
||||||
c_kzg_4844.o: c_kzg_4844.c Makefile
|
c_kzg_4844.o: c_kzg_4844.c Makefile
|
||||||
${CLANG_EXECUTABLE} -Wall -I$(INCLUDE_DIRS) -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) $(CFLAGS) -c $<
|
${CLANG_EXECUTABLE} -Wall -I$(INCLUDE_DIRS) -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB) $(CFLAGS) -c $<
|
||||||
|
|
||||||
# Will fail with "patch does not apply" if it has already been patched.
|
|
||||||
# Safe to ignore.
|
|
||||||
blst:
|
blst:
|
||||||
cd ../blst; \
|
cd ../blst; \
|
||||||
git apply < ../blst_sha.patch; \
|
|
||||||
${BLST_BUILD_SCRIPT} && \
|
${BLST_BUILD_SCRIPT} && \
|
||||||
cp libblst.a ../lib && \
|
cp libblst.a ../lib && \
|
||||||
cp bindings/*.h ../inc
|
cp bindings/*.h ../inc
|
||||||
|
|
|
@ -527,28 +527,6 @@ static void bytes_of_uint64(uint8_t out[8], uint64_t n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// SHA-256 Hash Functions
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int h[8];
|
|
||||||
unsigned long long N;
|
|
||||||
unsigned char buf[64];
|
|
||||||
size_t off;
|
|
||||||
} SHA256_CTX;
|
|
||||||
|
|
||||||
void sha256_init(SHA256_CTX *ctx);
|
|
||||||
void sha256_update(SHA256_CTX *ctx, const void *_inp, size_t len);
|
|
||||||
void sha256_final(unsigned char md[32], SHA256_CTX *ctx);
|
|
||||||
|
|
||||||
static void hash(uint8_t md[32], const uint8_t *input, size_t n) {
|
|
||||||
SHA256_CTX ctx;
|
|
||||||
sha256_init(&ctx);
|
|
||||||
sha256_update(&ctx, input, n);
|
|
||||||
sha256_final(md, &ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Bit-reversal Permutation Functions
|
// Bit-reversal Permutation Functions
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -724,7 +702,7 @@ static C_KZG_RET compute_challenges(fr_t *eval_challenge_out, fr_t *r_powers_out
|
||||||
|
|
||||||
/* Now let's create challenges! */
|
/* Now let's create challenges! */
|
||||||
uint8_t hashed_data[32] = {0};
|
uint8_t hashed_data[32] = {0};
|
||||||
hash(hashed_data, bytes, nb);
|
blst_sha256(hashed_data, bytes, nb);
|
||||||
|
|
||||||
/* We will use hash_input in the computation of both challenges */
|
/* We will use hash_input in the computation of both challenges */
|
||||||
uint8_t hash_input[33];
|
uint8_t hash_input[33];
|
||||||
|
@ -733,7 +711,7 @@ static C_KZG_RET compute_challenges(fr_t *eval_challenge_out, fr_t *r_powers_out
|
||||||
Bytes32 r_bytes;
|
Bytes32 r_bytes;
|
||||||
memcpy(hash_input, hashed_data, 32);
|
memcpy(hash_input, hashed_data, 32);
|
||||||
hash_input[32] = 0x0;
|
hash_input[32] = 0x0;
|
||||||
hash(r_bytes.bytes, hash_input, 33);
|
blst_sha256(r_bytes.bytes, hash_input, 33);
|
||||||
|
|
||||||
/* Compute r_powers */
|
/* Compute r_powers */
|
||||||
fr_t r;
|
fr_t r;
|
||||||
|
@ -743,7 +721,7 @@ static C_KZG_RET compute_challenges(fr_t *eval_challenge_out, fr_t *r_powers_out
|
||||||
/* Compute eval_challenge */
|
/* Compute eval_challenge */
|
||||||
Bytes32 eval_challenge;
|
Bytes32 eval_challenge;
|
||||||
hash_input[32] = 0x1;
|
hash_input[32] = 0x1;
|
||||||
hash(eval_challenge.bytes, hash_input, 33);
|
blst_sha256(eval_challenge.bytes, hash_input, 33);
|
||||||
hash_to_bls_field(eval_challenge_out, &eval_challenge);
|
hash_to_bls_field(eval_challenge_out, &eval_challenge);
|
||||||
|
|
||||||
free(bytes);
|
free(bytes);
|
||||||
|
|
Loading…
Reference in New Issue