Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Jun 30, 2024
1 parent 1a36a3e commit 81a7091
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ci

on:
push:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- run: cc -v
- run: make build
- run: ./ecloop -v
- run: ./ecloop add -f data/btc-puzzles-hash -r 8000:ffff -q -o /dev/null
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ clean:
@rm -rf ecloop bench main a.out *.profraw *.profdata

build: clean
@CC $(CC_FLAGS) main.c -o ecloop
@$(CC) $(CC_FLAGS) main.c -o ecloop

add: build
./ecloop add -f data/btc-puzzles-hash -t 8 -r 8000:ffffff -v
./ecloop add -f data/btc-puzzles-hash -t 8 -r 8000:ffffff

mul: build
cat data.txt | ./ecloop mul -f _check_1.txt -t 8 -a cu -v
cat data.txt | ./ecloop mul -f _check_1.txt -t 8 -a cu

blf-test: build
@rm -rf /tmp/test.blf
cat data/btc-puzzles-hash | ./ecloop blf-gen -n 1024 -o /tmp/test.blf
./ecloop add -f /tmp/test.blf -t 8 -r 8000:ffffff -v
./ecloop add -f /tmp/test.blf -t 8 -r 8000:ffffff
18 changes: 9 additions & 9 deletions lib/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void sha256_final(u32 state[8], const u8 data[], u32 length) {
static inline u32 rotr(u32 x, u32 n) { return (x >> n) | (x << (32 - n)); }
static inline u32 MAJ(u32 a, u32 b, u32 c) { return (a & b) ^ (a & c) ^ (b & c); }
static inline u32 CH(u32 e, u32 f, u32 g) { return (e & f) ^ (~e & g); }
static inline void round(u32 a, u32 b, u32 c, u32 *d, u32 e, u32 f, u32 g, u32 *h, u32 m, u32 k) {
static inline void ROUND(u32 a, u32 b, u32 c, u32 *d, u32 e, u32 f, u32 g, u32 *h, u32 m, u32 k) {
u32 s = CH(e, f, g) + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + k + m;
*d += s + *h;
*h += s + MAJ(a, b, c) + (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22));
Expand Down Expand Up @@ -426,14 +426,14 @@ void sha256_final(u32 state[8], const u8 data[], u32 length) {
}

for (int i = 0; i < 64; i += 8) {
round(a, b, c, &d, e, f, g, &h, w[i + 0], SHA256_K[i + 0]);
round(h, a, b, &c, d, e, f, &g, w[i + 1], SHA256_K[i + 1]);
round(g, h, a, &b, c, d, e, &f, w[i + 2], SHA256_K[i + 2]);
round(f, g, h, &a, b, c, d, &e, w[i + 3], SHA256_K[i + 3]);
round(e, f, g, &h, a, b, c, &d, w[i + 4], SHA256_K[i + 4]);
round(d, e, f, &g, h, a, b, &c, w[i + 5], SHA256_K[i + 5]);
round(c, d, e, &f, g, h, a, &b, w[i + 6], SHA256_K[i + 6]);
round(b, c, d, &e, f, g, h, &a, w[i + 7], SHA256_K[i + 7]);
ROUND(a, b, c, &d, e, f, g, &h, w[i + 0], SHA256_K[i + 0]);
ROUND(h, a, b, &c, d, e, f, &g, w[i + 1], SHA256_K[i + 1]);
ROUND(g, h, a, &b, c, d, e, &f, w[i + 2], SHA256_K[i + 2]);
ROUND(f, g, h, &a, b, c, d, &e, w[i + 3], SHA256_K[i + 3]);
ROUND(e, f, g, &h, a, b, c, &d, w[i + 4], SHA256_K[i + 4]);
ROUND(d, e, f, &g, h, a, b, &c, w[i + 5], SHA256_K[i + 5]);
ROUND(c, d, e, &f, g, h, a, &b, w[i + 6], SHA256_K[i + 6]);
ROUND(b, c, d, &e, f, g, h, &a, w[i + 7], SHA256_K[i + 7]);
}

state[0] += a;
Expand Down
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ void usage(const char *name) {
}

void init(ctx_t *ctx, args_t *args) {
// check bench commands first
// check other commands first
if (args->argc > 1) {
if (strcmp(args->argv[1], "blf-gen") == 0) return blf_gen(args);
if (strcmp(args->argv[1], "bench") == 0) return run_bench();
Expand All @@ -712,7 +712,7 @@ void init(ctx_t *ctx, args_t *args) {
if (ctx->cmd == CMD_NIL) {
if (args_bool(args, "-v")) printf("ecloop v%s\n", VERSION);
else usage(args->argv[0]);
exit(1);
exit(0);
}

char *path = arg_str(args, "-f");
Expand Down

0 comments on commit 81a7091

Please sign in to comment.