-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2aadb6f
commit fdb6ec2
Showing
16 changed files
with
363 additions
and
19 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,13 @@ | ||
import { BlsG1 } from "@harmoniclabs/crypto"; | ||
import { PType } from "../PType"; | ||
|
||
export class PBlsG1 extends PType | ||
{ | ||
private _pblsg1: BlsG1 | ||
|
||
constructor( bs: BlsG1 ) | ||
{ | ||
super(); | ||
this._pblsg1 = bs; | ||
} | ||
} |
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,13 @@ | ||
import { BlsG2 } from "@harmoniclabs/crypto"; | ||
import { PType } from "../PType"; | ||
|
||
export class PBlsG2 extends PType | ||
{ | ||
private _pblsg2: BlsG2 | ||
|
||
constructor( bs: BlsG2 ) | ||
{ | ||
super(); | ||
this._pblsg2 = bs; | ||
} | ||
} |
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,13 @@ | ||
import { BlsResult } from "@harmoniclabs/crypto"; | ||
import { PType } from "../PType"; | ||
|
||
export class PBlsMlRes extends PType | ||
{ | ||
private _pblsRes: BlsResult | ||
|
||
constructor( bs: BlsResult ) | ||
{ | ||
super(); | ||
this._pblsRes = bs; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,5 +10,4 @@ export class PByteString extends PDataRepresentable | |
super(); | ||
this._pbytestring = bs; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
packages/onchain/src/pluts/lib/builtins/bls12_381_G1_element/index.ts
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,72 @@ | ||
import { PBlsG1 } from "../../../PTypes/PBlsG1"; | ||
import { blsG1, bool, bs, fn, int } from "../../../type_system/types"; | ||
import { IRNative } from "../../../../IR/IRNodes/IRNative"; | ||
import { Term } from "../../../Term"; | ||
import { PFn } from "../../../PTypes/PFn/PFn"; | ||
import { PInt } from "../../../PTypes/PInt"; | ||
import type { PByteString } from "../../../PTypes/PByteString"; | ||
import { PBool } from "../../../PTypes/PBool"; | ||
import { addApplications } from "../addApplications"; | ||
|
||
export const bls12_381_G1_element_add = addApplications<[ PBlsG1, PBlsG1 ], PBlsG1>( | ||
new Term( | ||
fn([ blsG1, blsG1 ], blsG1 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_add; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_neg = addApplications<[ PBlsG1 ], PBlsG1>( | ||
new Term( | ||
fn([ blsG1 ], blsG1 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_neg; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_scalarMul = addApplications<[ PInt, PBlsG1 ], PBlsG1>( | ||
new Term( | ||
fn([ int, blsG1 ], blsG1 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_scalarMul; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_eq = addApplications<[ PBlsG1, PBlsG1 ], PBool>( | ||
new Term( | ||
fn([ blsG1, blsG1 ], bool ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_equal; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_hashToGroup = addApplications<[ PByteString, PByteString ], PBlsG1>( | ||
new Term( | ||
fn([ bs, bs ], blsG1 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_hashToGroup; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_compress = addApplications<[ PBlsG1 ], PByteString>( | ||
new Term( | ||
fn([ blsG1 ], bs ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_compress; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G1_element_uncompress = addApplications<[ PByteString ], PBlsG1>( | ||
new Term( | ||
fn([ bs ], blsG1 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G1_uncompress; | ||
} | ||
) | ||
); |
72 changes: 72 additions & 0 deletions
72
packages/onchain/src/pluts/lib/builtins/bls12_381_G2_element/index.ts
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,72 @@ | ||
import { PBlsG2 } from "../../../PTypes/PBlsG2"; | ||
import { blsG2, bool, bs, fn, int } from "../../../type_system/types"; | ||
import { IRNative } from "../../../../IR/IRNodes/IRNative"; | ||
import { Term } from "../../../Term"; | ||
import { PFn } from "../../../PTypes/PFn/PFn"; | ||
import { PInt } from "../../../PTypes/PInt"; | ||
import type { PByteString } from "../../../PTypes/PByteString"; | ||
import { PBool } from "../../../PTypes/PBool"; | ||
import { addApplications } from "../addApplications"; | ||
|
||
export const bls12_381_G2_element_add = addApplications<[ PBlsG2, PBlsG2 ], PBlsG2>( | ||
new Term( | ||
fn([ blsG2, blsG2 ], blsG2 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_add; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_neg = addApplications<[ PBlsG2 ], PBlsG2>( | ||
new Term( | ||
fn([ blsG2 ], blsG2 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_neg; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_scalarMul = addApplications<[ PInt, PBlsG2 ], PBlsG2>( | ||
new Term( | ||
fn([ int, blsG2 ], blsG2 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_scalarMul; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_eq = addApplications<[ PBlsG2, PBlsG2 ], PBool>( | ||
new Term( | ||
fn([ blsG2, blsG2 ], bool ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_equal; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_hashToGroup = addApplications<[ PByteString, PByteString ], PBlsG2>( | ||
new Term( | ||
fn([ bs, bs ], blsG2 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_hashToGroup; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_compress = addApplications<[ PBlsG2 ], PByteString>( | ||
new Term( | ||
fn([ blsG2 ], bs ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_compress; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_G2_element_uncompress = addApplications<[ PByteString ], PBlsG2>( | ||
new Term( | ||
fn([ bs ], blsG2 ), | ||
_dbn => { | ||
return IRNative.bls12_381_G2_uncompress; | ||
} | ||
) | ||
); |
34 changes: 34 additions & 0 deletions
34
packages/onchain/src/pluts/lib/builtins/bls12_381_MlResult/index.ts
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,34 @@ | ||
import { PBlsG2 } from "../../../PTypes/PBlsG2"; | ||
import { blsG1, blsG2, blsResult, bool, fn } from "../../../type_system/types"; | ||
import { IRNative } from "../../../../IR/IRNodes/IRNative"; | ||
import { Term } from "../../../Term"; | ||
import { PBool } from "../../../PTypes/PBool"; | ||
import { PBlsMlRes } from "../../../PTypes/PBlsMlRes"; | ||
import { addApplications } from "../addApplications"; | ||
|
||
export const bls12_381_millerLoop = addApplications<[ PBlsG2, PBlsG2 ], PBlsMlRes>( | ||
new Term( | ||
fn([ blsG1, blsG2 ], blsResult ), | ||
_dbn => { | ||
return IRNative.bls12_381_millerLoop; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_mulMlResult = addApplications<[ PBlsMlRes, PBlsMlRes ], PBlsMlRes>( | ||
new Term( | ||
fn([ blsResult, blsResult ], blsResult ), | ||
_dbn => { | ||
return IRNative.bls12_381_mulMlResult; | ||
} | ||
) | ||
); | ||
|
||
export const bls12_381_finalVerify = addApplications<[ PBlsMlRes, PBlsMlRes ], PBool>( | ||
new Term( | ||
fn([ blsResult, blsResult ], bool ), | ||
_dbn => { | ||
return IRNative.bls12_381_finalVerify; | ||
} | ||
) | ||
); |
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
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
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
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
Oops, something went wrong.