Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.0 errata, move to tmio for tuweni dep #182

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arithmetic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
dependencies {
implementation 'net.java.dev.jna:jna:5.12.1'
testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'org.apache.tuweni:tuweni-bytes:2.2.0'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
Expand Down
4 changes: 2 additions & 2 deletions bls12-381/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Hyperledger Besu contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -23,7 +23,7 @@ dependencies {
implementation 'net.java.dev.jna:jna:5.12.1'
testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.apache.tuweni:tuweni-bytes:2.2.0'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
}

Expand Down
3 changes: 2 additions & 1 deletion gnark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ plugins {

dependencies {
implementation 'net.java.dev.jna:jna:5.12.1'
testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'net.java.dev.jna:jna:5.12.1'
implementation 'org.apache.tuweni:tuweni-bytes:2.2.0'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.mockito:mockito-core:4.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
import org.apache.tuweni.bytes.Bytes;

public class LibGnarkEIP196 {

Expand Down Expand Up @@ -61,15 +60,23 @@ public static int eip196_perform_operation(
}

if (ret != 0) {
var errBytes = Bytes.wrap(err);
err_len.setValue(errBytes.size() - errBytes.numberOfTrailingZeroBytes());
err_len.setValue(LibGnarkUtils.findFirstTrailingZeroIndex(err));
o_len.setValue(0);
} else {
err_len.setValue(0);
}
return ret;
}

public int findFirstTrailingZeroIndex(byte[] array) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is implemented in the Utils class. I think this is not needed ...
You are even using the Utils implementation further up :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where? would love to DRY this out, but I don't see the usage you are talking about

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found and removed ;). thx

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation has no usages, and can now be removed.

for (int i = array.length - 1; i >= 0; i--) {
if (array[i] != 0) {
return i + 1; // The first trailing zero is after this non-zero byte
}
}
// If all bytes are zero, return 0
return 0;
}
pinges marked this conversation as resolved.
Show resolved Hide resolved

public static native int eip196altbn128G1Add(
byte[] input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
import org.apache.tuweni.bytes.Bytes;

import java.nio.charset.StandardCharsets;

public class LibGnarkEIP2537 implements Library {

Expand Down Expand Up @@ -110,8 +107,7 @@ public static int eip2537_perform_operation(
}

if (ret != 0) {
var errBytes = Bytes.wrap(err);
err_len.setValue(errBytes.size() - errBytes.numberOfTrailingZeroBytes());
err_len.setValue(LibGnarkUtils.findFirstTrailingZeroIndex(err));
o_len.setValue(0);
} else {
err_len.setValue(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.hyperledger.besu.nativelib.gnark;

public class LibGnarkUtils {

public static int findFirstTrailingZeroIndex(byte[] array) {
for (int i = array.length - 1; i >= 0; i--) {
if (array[i] != 0) {
return i + 1; // The first trailing zero is after this non-zero byte
}
}
// If all bytes are zero, return 0
return 0;
}
}
2 changes: 1 addition & 1 deletion ipa-multipoint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

dependencies {
implementation 'net.java.dev.jna:jna:5.12.1'
testImplementation 'org.apache.tuweni:tuweni-bytes:2.3.1'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.5'
Expand Down
4 changes: 2 additions & 2 deletions secp256r1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Hyperledger Besu contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -24,7 +24,7 @@ dependencies {

testImplementation 'com.google.guava:guava:31.1-jre'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.apache.tuweni:tuweni-bytes:2.2.0'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
}

Expand Down
Loading