Skip to content

Commit 16f54c6

Browse files
committed
Update and rewrite
1 parent e2f47bc commit 16f54c6

26 files changed

+482
-351
lines changed

.cspell.jsonc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"words": [
3+
"ecdh",
4+
"libsecp256k1",
5+
"secp256k1",
6+
"seckey"
7+
],
8+
"ignorePaths": [
9+
".gitignore",
10+
"LICENSE"
11+
]
12+
}

.github/workflows/cd.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CD
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
name: Push gem to RubyGems.org
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
15+
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
persist-credentials: false
20+
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
bundler-cache: true
25+
ruby-version: ruby
26+
27+
- uses: rubygems/release-gem@v1

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
ruby-version: ['3.2', '3.3', '3.4']
16+
17+
steps:
18+
- uses: actions/checkout@v5
19+
with:
20+
submodules: true
21+
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: ${{ matrix.ruby-version }}
26+
27+
- name: Install build tools on macOS
28+
if: runner.os == 'macOS'
29+
run: brew install automake libtool
30+
31+
- name: Install dependencies
32+
run: bundle install
33+
34+
- name: Build secp256k1
35+
run: ./make.sh
36+
37+
- name: Run tests
38+
run: ./test.sh

.gitignore

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
1-
.bundle
2-
tmp
3-
lib/ethash/ethash.so
4-
tags
1+
*.gem
2+
*.rbc
3+
/.config
4+
/coverage/
5+
/InstalledFiles
6+
/pkg/
7+
/spec/reports/
8+
/spec/examples.txt
9+
/test/tmp/
10+
/test/version_tmp/
11+
/tmp/
12+
13+
# Used by dotenv library to load environment variables.
14+
# .env
15+
16+
# Ignore Byebug command history file.
17+
.byebug_history
18+
19+
## Specific to RubyMotion:
20+
.dat*
21+
.repl_history
22+
build/
23+
*.bridgesupport
24+
build-iPhoneOS/
25+
build-iPhoneSimulator/
26+
27+
## Specific to RubyMotion (use of CocoaPods):
28+
#
29+
# We recommend against adding the Pods directory to your .gitignore. However
30+
# you should judge for yourself, the pros and cons are mentioned at:
31+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32+
#
33+
# vendor/Pods/
34+
35+
## Documentation cache and generated files:
36+
/.yardoc/
37+
/_yardoc/
38+
/doc/
39+
/rdoc/
40+
41+
## Environment normalization:
42+
/.bundle/
43+
/vendor/bundle
44+
/lib/bundler/man/
45+
46+
# for a library or gem, you might want to ignore these files since the code is
47+
# intended to run in multiple environments; otherwise, check them in:
48+
# Gemfile.lock
49+
# .ruby-version
50+
# .ruby-gemset
51+
52+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53+
.rvmrc
54+
55+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
56+
# .rubocop-https?--*

.travis.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Changelog
3+
4+
## 0.6.0
5+
6+
The first rewritten version, superseding [ruby-bitcoin-secp256k1](https://github.com/cryptape/ruby-bitcoin-secp256k1).

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22
gemspec

Gemfile.lock

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
PATH
22
remote: .
33
specs:
4-
bitcoin-secp256k1 (0.5.2)
5-
ffi (>= 1.9.25)
4+
libsecp256k1 (0.6.0)
5+
ffi (>= 1.17.2)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
ffi (1.11.1)
11-
minitest (5.11.3)
12-
rake (12.3.2)
13-
yard (0.9.20)
10+
ffi (1.17.2)
11+
ffi (1.17.2-aarch64-linux-gnu)
12+
ffi (1.17.2-aarch64-linux-musl)
13+
ffi (1.17.2-arm-linux-gnu)
14+
ffi (1.17.2-arm-linux-musl)
15+
ffi (1.17.2-arm64-darwin)
16+
ffi (1.17.2-x86-linux-gnu)
17+
ffi (1.17.2-x86-linux-musl)
18+
ffi (1.17.2-x86_64-darwin)
19+
ffi (1.17.2-x86_64-linux-gnu)
20+
ffi (1.17.2-x86_64-linux-musl)
1421

1522
PLATFORMS
23+
aarch64-linux-gnu
24+
aarch64-linux-musl
25+
arm-linux-gnu
26+
arm-linux-musl
27+
arm64-darwin
1628
ruby
29+
x86-linux-gnu
30+
x86-linux-musl
31+
x86_64-darwin
32+
x86_64-linux-gnu
33+
x86_64-linux-musl
1734

1835
DEPENDENCIES
19-
bitcoin-secp256k1!
20-
minitest (= 5.11.3)
21-
rake (~> 12.3)
22-
yard (= 0.9.20)
36+
libsecp256k1!
2337

2438
BUNDLED WITH
25-
1.17.2
39+
2.7.2

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Jan Xie
3+
Copyright (c) 2025 Weiliang Li
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,41 @@
1-
# ruby-bitcoin-secp256k1
1+
# libsecp256k1-rb
22

3-
## Prerequisite
3+
A Ruby FFI binding for bitcoin's secp256k1 library, superseding [ruby-bitcoin-secp256k1](https://github.com/cryptape/ruby-bitcoin-secp256k1).
44

5-
In order to use this gem, [libsecp256k1](https://github.com/bitcoin/secp256k1) must be in place.
5+
## Prerequisite
66

7-
### macOS
7+
In order to use this gem, bitcoins's [secp256k1](https://github.com/bitcoin-core/secp256k1) must be in place.
88

9-
```bash
10-
brew tap nervosnetwork/tap
11-
brew install libsecp256k1
12-
```
9+
### Install secp256k1
1310

14-
### Ubuntu 18.04 or above
11+
Use Homebrew:
1512

1613
```bash
17-
sudo apt install libsecp256k1-dev
18-
```
19-
20-
### Ubuntu 16.04 or below
21-
22-
```
23-
$ git clone https://github.com/bitcoin-core/secp256k1.git && cd secp256k1
24-
$ ./autogen.sh
25-
$ ./configure
26-
$ make
27-
$ sudo make install
14+
brew install secp256k1
2815
```
2916

30-
Or if you have cloned the project, you could go to project root and run this install script:
17+
Or build locally:
3118

32-
```
19+
```bash
3320
git submodule update --init --recursive
34-
./install_lib.sh
21+
./make.sh
22+
./test.sh
3523
```
3624

37-
The recovery and ecdh modules are optional. If your local installation of secp256k1 doesn't enable them then the gem would throw `LoadModuleError` when related functions are invoked.
38-
3925
## Install
4026

41-
```
42-
gem i bitcoin-secp256k1
27+
```bash
28+
gem i libsecp256k1
4329
```
4430

45-
Then `require 'secp256k1'` (without `bitcoin-` prefix) in your source code.
31+
Then `require "secp256k1"` in your source code.
4632

47-
## Usage
33+
You need to set `C_INCLUDE_PATH` and `LD_LIBRARY_PATH` (or `SECP256K1_LIB_PATH`) environment variables, see [./test.sh](./test.sh) for usage.
4834

49-
Check [test](test) for examples.
35+
## Examples
5036

51-
## LICENSE
37+
Check [test](./tests/) for examples.
5238

53-
[MIT License](LICENSE)
39+
## LICENSE
5440

41+
[MIT License](./LICENSE)

0 commit comments

Comments
 (0)