This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial setup including github docs, readme, and header file. Signed-off-by: Mikaela <[email protected]>
- Loading branch information
mikaelaTar
authored
Sep 22, 2020
1 parent
3e2f28f
commit c59bdca
Showing
12 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# How to contribute | ||
|
||
*We are still working on improving these guidelines.* | ||
|
||
Thank you for taking the time to contribute to `hyperledger/ursa-wrapper-go`! | ||
|
||
Contributing: | ||
* Submit a [bug report](#bug-report) | ||
* Submit a [pull request](#pull-request) | ||
|
||
## Bug Report | ||
|
||
Did you find a bug? Be sure to set a clear and concise title. Do your best to | ||
include a code sample that illustrates the test case. Use the | ||
[template](ISSUE_TEMPLATE.md). | ||
|
||
## Pull Request | ||
|
||
Use the [template](PULL_REQUEST_TEMPLATE.md) and make sure: | ||
|
||
* **Required:** The build must pass. | ||
* **Required:** Adherence to the [Developer Certificate of Origin | ||
(DCO)](https://developercertificate.org/) version 1.1 (`git --signoff`). | ||
* **Required:** *squash your commits*. Yes, we know - it's nice to be able to | ||
rollback every single change you make while troubleshooting or when requested to | ||
exclude a subset or your change. The problem is the project's history tends to | ||
become polluted with useless commit messages such as "removed trailing spaces". | ||
It also makes it harder to revert specific changes when they are spread out like | ||
this. We care about preserving our project's commit history in a usable state, | ||
and as such, we politely request that you deliver your changes in a single | ||
commit. | ||
* Number of lines changed should not exceed 500. We're reasonable people - if | ||
your PR is just a *little* over the top then we might still merge it. Such cases | ||
are exceptional and are handled on a case-by-case basis. | ||
|
||
The contents of this file are heavily "borrowed" from aries-framework-go, mainly because it is are good. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Use the following template for your bug report | ||
(make sure you follow our [guidelines](CONTRIBUTING.md#bug-report): | ||
|
||
**What I'm trying to do** | ||
|
||
[Clearly describe what you're trying to do.] | ||
|
||
**Expected result** | ||
|
||
[Clearly describe the result you **expect**.] | ||
|
||
**Actual result** | ||
|
||
[Clearly describe the **actual** result you get.] | ||
|
||
**Sample code / test case** | ||
|
||
[Include a code sample that illustrates the test case.] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Use the following template for your PR (make sure you follow our | ||
[guidelines](CONTRIBUTING.md#pull-request): | ||
|
||
**Title:** | ||
[Descriptive but using as few words as possible] | ||
|
||
**Description:** | ||
[Link to the GitHub issue it solves (if any)] | ||
|
||
Summary: | ||
|
||
[Include a brief summary of your changes] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build | ||
.idea/ | ||
coverage.txt | ||
*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.PHONY= all | ||
|
||
all: unit-test cover | ||
|
||
unit-test: | ||
@scripts/test.sh | ||
|
||
cover: | ||
go test -coverprofile cover.out ./pkg/... | ||
go tool cover -html=cover.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[![Release](https://img.shields.io/github/release/hyperledger/ursa-wrapper-go.svg?style=flat-square)](https://github.com/hyperledger/ursa-wrapper-go/releases/latest) | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/hyperledger/ursa-wrapper-go/main/LICENSE) | ||
[![Godocs](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/hyperledger/ursa-wrapper-go) | ||
|
||
[![codecov](https://codecov.io/gh/hyperledger/ursa-wrapper-go/branch/main/graph/badge.svg?token=dXh8Imy2PO)](https://codecov.io/gh/hyperledger/ursa-wrapper-go) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/hyperledger/ursa-wrapper-go)](https://goreportcard.com/report/github.com/hyperledger/ursa-wrapper-go) | ||
|
||
## ursa-wrapper-go | ||
|
||
- Ursa Wrapper Go requires the [Ursa](https://github.com/hyperledger/ursa) shared library to be installed (eg: /usr/local/lib), and `ursa-wrapper-go.sh` to be sourced. | ||
|
||
```shell script | ||
source ursa-wrapper-go.sh | ||
``` | ||
|
||
#### Development | ||
- `make test` to run unit tests | ||
|
||
#### Requirements | ||
- Golang >= `1.14.4` and CGO enabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/hyperledger/ursa-wrapper-go | ||
|
||
go 1.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdint.h> | ||
|
||
typedef enum { | ||
Success = 0, | ||
CommonInvalidParam1 = 100, | ||
CommonInvalidParam2 = 101, | ||
CommonInvalidParam3 = 102, | ||
CommonInvalidParam4 = 103, | ||
CommonInvalidParam5 = 104, | ||
CommonInvalidParam6 = 105, | ||
CommonInvalidParam7 = 106, | ||
CommonInvalidParam8 = 107, | ||
CommonInvalidParam9 = 108, | ||
CommonInvalidParam10 = 109, | ||
CommonInvalidParam11 = 110, | ||
CommonInvalidParam12 = 111, | ||
CommonInvalidState = 112, | ||
CommonInvalidStructure = 113, | ||
CommonIOError = 114, | ||
AnoncredsRevocationAccumulatorIsFull = 115, | ||
AnoncredsInvalidRevocationAccumulatorIndex = 116, | ||
AnoncredsCredentialRevoked = 117, | ||
AnoncredsProofRejected = 118, | ||
} ursa_error_t; | ||
|
||
struct ExternError { | ||
ursa_error_t code; | ||
char* message; /* note: nullable */ | ||
}; | ||
|
||
struct ExternError ursa_cl_new_nonce(void** nonce_p); | ||
struct ExternError ursa_cl_nonce_to_json(void* nonce, const char** nonce_json_p); | ||
extern void ursa_get_current_error(const char** error_json_p); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ursa | ||
|
||
/* | ||
#cgo LDFLAGS: -lursa | ||
#include "ursa_cl.h" | ||
#include <stdlib.h> | ||
*/ | ||
import "C" | ||
import ( | ||
"errors" | ||
"unsafe" | ||
) | ||
|
||
func NewNonce() (string, error) { | ||
var nonce unsafe.Pointer | ||
defer C.free(nonce) | ||
|
||
var d *C.char | ||
defer C.free(unsafe.Pointer(d)) | ||
|
||
result := C.ursa_cl_new_nonce(&nonce) | ||
if result.code != 0 { | ||
C.ursa_get_current_error(&result.message) | ||
return "", errors.New(C.GoString(result.message)) | ||
} | ||
|
||
result = C.ursa_cl_nonce_to_json(nonce, &d) | ||
if result.code != 0 { | ||
return "", errors.New(C.GoString(result.message)) | ||
} | ||
|
||
return C.GoString(d), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ursa | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestNewNonce(t *testing.T) { | ||
t.Run("NewNonce", func(t *testing.T) { | ||
n, err := NewNonce() | ||
if n == "" { | ||
t.Errorf("NewNonce() returned blank value") | ||
} | ||
|
||
if err != nil { | ||
t.Errorf("NewNonce() returned error") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
echo "" >coverage.txt | ||
|
||
for d in $(go list ./pkg/... | grep -v vendor); do | ||
go test -race -coverprofile=profile.out -covermode=atomic $d | ||
if [ -f profile.out ]; then | ||
cat profile.out >>coverage.txt | ||
rm profile.out | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
PWD=$(pwd) | ||
export URSA_GO_ROOT=$PWD | ||
export PATH=$PWD/bin:$PATH | ||
|
||
export CGO_CFLAGS=-I"${URSA_GO_ROOT}"/include |