Sign In

@celo/poprf

Package Overview
Dependencies
Maintainers
18
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@celo/poprf

A threshold-computable partially-oblivous psuedo-random function

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
42
-6.67%
Maintainers
18
Weekly downloads
 
Created
Source

Celo POPRF

This repository implements a threshold-computable partially-oblivious pseudo-random function (POPRF) with evaluations that are verifiable by the client.

Specification

WASM bindings

This library provides WASM bindings for signing under the ffi/wasm.rs module. These can be built via the wasm-pack tool. Depending on the platform you are targeting, you'll need to use a different build flag.

Note: You can also replace celo with your own NPM username to test publish.

# Builds the WASM and wraps it as NPM package @celo/poprf
$ wasm-pack build --target nodejs --scope celo -- --features=wasm

The bundled WASM package will be under the pkg/ directory. You can then either pack and publish it with wasm-pack's pack and publish commands, or manually import it in your application.

$ wasm-pack publish --access public

TypeScript usage

Here is an example of using the library. In practice there will be a client and a server, with the assumption that the client holds the message and the server holds the private key. In this snippet, both client and server are represented.

import * as poprf from '@celo/poprf'
import 'crypto'

const message = Buffer.from("message")
const tag = Buffer.from("tag")

// Generate a local keypair for demonstration purposes.
const keypair = poprf.keygen(crypto.randomBytes(32))

// Client: Blind the message to send to the server.
const { blindedMessage, blindingFactor } = poprf.blindMsg(message, crypto.randomBytes(32))

// Server: Evaluate the POPRF over the blinded message and tag.
const response = poprf.blindEval(keypair.privateKey, tag, blindedMessage)

// Client: Unblind and verify the evaluation returned from the server.
const result = poprf.unblindResp(keypair.publicKey, blindingFactor, tag, response)

FAQs

Package last updated on 01 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts