GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ecies/rb: Elliptic Curve Integrated Encryption Scheme for secp256k1 in Ruby

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
lib
lib
 
 
tests
tests
 
 
.cspell.jsonc
.cspell.jsonc
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
eciesrb.gemspec
eciesrb.gemspec
 
 

Repository files navigation

eciesrb

Gem Version License CI

Elliptic Curve Integrated Encryption Scheme for secp256k1 in Ruby.

This is a Ruby port of eciespy.

Prerequisite

Make sure you have secp256k1 and openssl installed, if not:

brew install secp256k1 openssl

Then set environment variables:

export C_INCLUDE_PATH=$(brew --prefix secp256k1)/include

Install

gem install eciesrb

Quick Start

# examples/quickstart.rb
require "ecies"

# Generate a secret key
sk = Ecies.generate_key
raw_sk = Ecies.decode_hex(sk.send(:serialize))
raw_pk = sk.pubkey.serialize(compressed: false)

# Encrypt data with the receiver's public key
plaintext = "Hello, World!"
encrypted = Ecies.encrypt(raw_pk, plaintext)

# Decrypt data with the receiver's secret key
decrypted = Ecies.decrypt(raw_sk, encrypted)
puts decrypted  # => "Hello, World!"

Sponsors

dotenvx

Configuration

You can customize the encryption behavior using a Config object:

# examples/config.rb
require "ecies"

Ecies::DEFAULT_CONFIG.is_ephemeral_key_compressed = true   # Use compressed ephemeral public key
Ecies::DEFAULT_CONFIG.is_hkdf_key_compressed = true        # Use compressed key for HKDF
Ecies::DEFAULT_CONFIG.symmetric_nonce_length = 16          # Nonce length for AES-GCM (default: 16)

Configuration Parameters

  • is_ephemeral_key_compressed (Boolean): Whether to use compressed format for the ephemeral public key. Default: false
  • is_hkdf_key_compressed (Boolean): Whether to use compressed format for HKDF key derivation. Default: false
  • symmetric_nonce_length (Integer): The nonce length for AES-GCM encryption. Options: 12, 16. Default: 16

API Reference

encrypt(receiver_pk, data, config = DEFAULT_CONFIG)

Encrypts data using the receiver's public key.

Parameters:

  • receiver_pk (String): The receiver's public key (raw bytes, serialized)
  • data (String): The plaintext data to encrypt (raw bytes)
  • config (Ecies::Config): Optional configuration object

Returns: (String) The encrypted data (ephemeral public key + encrypted data)

decrypt(receiver_sk, data, config = DEFAULT_CONFIG)

Decrypts data using the receiver's secret key.

Parameters:

  • receiver_sk (String): The receiver's secret key (raw bytes, serialized)
  • data (String): The encrypted data (ephemeral public key + encrypted data)
  • config (Ecies::Config): Optional configuration object

Returns: (String) The decrypted plaintext data (raw bytes)

Changelog

See CHANGELOG.md.

About

Elliptic Curve Integrated Encryption Scheme for secp256k1 in Ruby

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.