Ship third-party licences and point to the exact source of each build (#36)

* Ship third-party licences and point to the exact source of each build

The light client links smoldot (GPL-3.0-or-later WITH Classpath-exception-2.0), and the app
shipped no third-party notices at all. Releases are not tagged, so nothing told a user which
source a given APK was built from.

- Settings > About gets an "Open source licenses" row. It opens the licences page with the commit
  the build was made from (BuildConfig.LICENCES_URL, from git rev-parse HEAD).
- assets/licences/rust-crates.txt lists the 430 Rust crates linked into the four native libraries,
  with their licence texts. scripts/licences/rust_notices.py writes it from the lockfiles, and a
  Code Quality job fails when it is stale.
- assets/licences/native-libraries.txt covers the prebuilt libsqlcipher.so and libsr25519java.so.
- The licensee plugin bundles the Android library list into the APK and fails the build on a
  licence outside the allowed set.
- NOTICE names the Pezkuwi Wallet copyright and where these notices live.

* Check Android library licences in Code Quality and keep the report

The build job fails on a disallowed licence but does not say which library, and its workflow is
taken from main. This job runs only the licence check on the PR branch and uploads the report
naming each library and its licence.

* Replace the GPL-3.0 NovaCrypto libraries and allow the reviewed licences

substrate-sdk-android brings in NovaCrypto BIP39, Sha256, ToRuntime and SecureString, all
GPL-3.0 without exception, which made the APK a GPL-3.0 combined work alongside Google's
proprietary SDKs. The SDK uses four of their types, only in MnemonicCreator and EnglishWordList.
common now provides those types under Apache-2.0 with the binary interface the SDK is compiled
against (taken from its bytecode), and every configuration excludes the NovaCrypto groups.

Bip39VectorsTest runs the SDK's MnemonicCreator on them against all 24 English BIP-0039 vectors,
both directions, plus a round trip of each random mnemonic length. Checked outside Gradle against
the SDK 2.11.0 classes: 24/24, and red when the checksum is broken.

The licence policy now names each remaining library licensee rejected: permissive licences
declared by URL, POMs without a licence (checked against each project's repository), Google's
SDK terms for the Play build, and the EPL libraries one by one.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-11-05 21:25:30 +04:00
1 parent 5c13c84eca
commit cf74df7cf4
27 files changed
+18831

No files matched your search

+13
View File
@@ -1,5 +1,15 @@
apply plugin: 'kotlin-parcelize'
String sourceCommit() {
try {
def process = ['git', 'rev-parse', 'HEAD'].execute()
def commit = process.text.trim()
return process.waitFor() == 0 && commit ==~ /[0-9a-f]{40}/ ? commit : ""
} catch (IOException ignored) {
return ""
}
}
android {
defaultConfig {
@@ -8,6 +18,9 @@ android {
buildConfigField "String", "PRIVACY_URL", "\"https://pezkuwichain.io/privacy.html\""
buildConfigField "String", "TERMS_URL", "\"https://pezkuwichain.io/terms.html\""
buildConfigField "String", "GITHUB_URL", "\"https://github.com/pezkuwichain\""
// Releases are not tagged, so the licences page is told which commit this build is made from:
// that is where the source the GPL-licensed light client requires us to offer lives.
buildConfigField "String", "LICENCES_URL", "\"https://pezkuwichain.github.io/pezkuwi-wallet-utils/licences/?commit=${sourceCommit()}\""
buildConfigField "String", "TELEGRAM_URL", "\"https://t.me/pezkuwichainBot\""
buildConfigField "String", "TWITTER_URL", "\"https://x.com/bizinikiwi\""
buildConfigField "String", "RATE_URL", "\"market://details?id=${rootProject.applicationId}.${releaseApplicationSuffix}\""
@@ -0,0 +1,36 @@
package io.github.novacrypto;
import java.io.Closeable;
import java.util.Arrays;
/**
* A character buffer that is wiped when closed, for assembling a mnemonic. See
* {@link io.github.novacrypto.bip39.WordList}.
*/
public final class SecureCharBuffer implements Closeable {
private char[] chars = new char[256];
private int length;
public void append(CharSequence text) {
if (length + text.length() > chars.length) {
char[] grown = Arrays.copyOf(chars, Math.max(chars.length * 2, length + text.length()));
Arrays.fill(chars, '\0');
chars = grown;
}
for (int i = 0; i < text.length(); i++) {
chars[length++] = text.charAt(i);
}
}
/** The content so far; the caller owns the copy it makes from it. */
public CharSequence toStringAble() {
return new String(chars, 0, length);
}
@Override
public void close() {
Arrays.fill(chars, '\0');
length = 0;
}
}
@@ -0,0 +1,52 @@
package io.github.novacrypto.bip39;
import io.github.novacrypto.hashing.Sha256;
/** Turns entropy into a BIP39 mnemonic, as specified in BIP-0039. See {@link WordList}. */
public final class MnemonicGenerator {
/** Receives the mnemonic piece by piece, so it never has to sit in an immutable String. */
public interface Target {
void append(CharSequence text);
}
private static final int BITS_PER_WORD = 11;
private final WordList wordList;
public MnemonicGenerator(WordList wordList) {
this.wordList = wordList;
}
/**
* Appends the words for {@code entropy} (16 to 32 bytes, a multiple of 4) to {@code target}: the
* entropy followed by the first length/32 bits of its SHA-256, read in groups of 11 bits.
*/
public void createMnemonic(byte[] entropy, Target target) {
if (entropy.length < 16 || entropy.length > 32 || entropy.length % 4 != 0) {
throw new IllegalArgumentException("Entropy must be 16 to 32 bytes, a multiple of 4: " + entropy.length);
}
byte[] checksum = Sha256.sha256(entropy);
int checksumBits = entropy.length * 8 / 32;
int words = (entropy.length * 8 + checksumBits) / BITS_PER_WORD;
String space = String.valueOf(wordList.getSpace());
for (int word = 0; word < words; word++) {
int index = 0;
for (int bit = word * BITS_PER_WORD; bit < (word + 1) * BITS_PER_WORD; bit++) {
index = (index << 1) | bitAt(entropy, checksum, bit);
}
if (word > 0) {
target.append(space);
}
target.append(wordList.getWord(index));
}
}
private static int bitAt(byte[] entropy, byte[] checksum, int bit) {
int entropyBits = entropy.length * 8;
byte[] source = bit < entropyBits ? entropy : checksum;
int position = bit < entropyBits ? bit : bit - entropyBits;
return (source[position / 8] >> (7 - position % 8)) & 1;
}
}
@@ -0,0 +1,18 @@
package io.github.novacrypto.bip39;
/**
* A BIP39 word list.
*
* <p>The classes under {@code io.github.novacrypto} are written for this app under Apache-2.0. They
* replace the GPL-3.0 NovaCrypto libraries that substrate-sdk-android depends on, and keep only the
* binary interface its MnemonicCreator and EnglishWordList are compiled against, so the SDK runs
* unchanged. The NovaCrypto artifacts are excluded in the root build.gradle.
*/
public interface WordList {
/** The word at {@code index}, 0 to 2047. */
String getWord(int index);
/** The character the words of a mnemonic are joined with. */
char getSpace();
}
@@ -0,0 +1,19 @@
package io.github.novacrypto.hashing;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/** SHA-256 from the platform. See {@link io.github.novacrypto.bip39.WordList}. */
public final class Sha256 {
private Sha256() {
}
public static byte[] sha256(byte[] bytes) {
try {
return MessageDigest.getInstance("SHA-256").digest(bytes);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("SHA-256 is required on every Java platform", e);
}
}
}
@@ -3,6 +3,7 @@ package io.novafoundation.nova.common.data.network
class AppLinksProvider(
val termsUrl: String,
val privacyUrl: String,
val licencesUrl: String,
val telegram: String,
val twitter: String,
val rateApp: String,
@@ -55,6 +55,7 @@ class NetworkModule {
return AppLinksProvider(
termsUrl = BuildConfig.TERMS_URL,
privacyUrl = BuildConfig.PRIVACY_URL,
licencesUrl = BuildConfig.LICENCES_URL,
payoutsLearnMore = BuildConfig.PAYOUTS_LEARN_MORE,
twitterAccountTemplate = BuildConfig.TWITTER_ACCOUNT_TEMPLATE,
setControllerLearnMore = BuildConfig.SET_CONTROLLER_LEARN_MORE,
@@ -1498,6 +1498,7 @@
<string name="about_contact_us">Têkilî bi me re</string>
<string name="about_github_v2_2_0">Github</string>
<string name="about_privacy">Siyaseta nepeniyê</string>
<string name="about_open_source_licences">Lîsansên çavkaniya vekirî</string>
<string name="about_rate_app">Me binirxîne</string>
<string name="about_telegram_v2_2_0">Telegram</string>
<string name="about_terms">Merc û şert</string>
@@ -1536,6 +1536,7 @@ Transfer sonrası kalan bakiye: %2$s</string>
<string name="about_contact_us">Bize Ulaşın</string>
<string name="about_github_v2_2_0">Github</string>
<string name="about_privacy">Gizlilik politikası</string>
<string name="about_open_source_licences">Açık kaynak lisansları</string>
<string name="about_rate_app">Bizi değerlendirin</string>
<string name="about_telegram_v2_2_0">Telegram</string>
<string name="about_terms">Şartlar ve koşullar</string>
+1
View File
@@ -2254,6 +2254,7 @@
<string name="about_contact_us">Contact Us</string>
<string name="about_github_v2_2_0">Github</string>
<string name="about_privacy">Privacy policy</string>
<string name="about_open_source_licences">Open source licenses</string>
<string name="about_rate_app">Rate us</string>
<string name="about_telegram_v2_2_0">Telegram</string>
<string name="about_terms">Terms and conditions</string>
@@ -0,0 +1,67 @@
package io.novafoundation.nova.common.utils
import io.novasama.substrate_sdk_android.encrypt.mnemonic.Mnemonic
import io.novasama.substrate_sdk_android.encrypt.mnemonic.MnemonicCreator
import io.novasama.substrate_sdk_android.extensions.fromHex
import io.novasama.substrate_sdk_android.extensions.toHexString
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
// The SDK's MnemonicCreator runs on the Apache-2.0 classes in io.github.novacrypto that replace the
// GPL-3.0 NovaCrypto libraries. A wrong word here would give users a phrase that restores another
// account, so every English vector of BIP-0039 (trezor/python-mnemonic vectors.json) is checked.
class Bip39VectorsTest {
private val vectors = listOf(
"00000000000000000000000000000000" to "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f" to "legal winner thank year wave sausage worth useful legal winner thank yellow",
"80808080808080808080808080808080" to "letter advice cage absurd amount doctor acoustic avoid letter advice cage above",
"ffffffffffffffffffffffffffffffff" to "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong",
"000000000000000000000000000000000000000000000000" to "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent",
"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f" to "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will",
"808080808080808080808080808080808080808080808080" to "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always",
"ffffffffffffffffffffffffffffffffffffffffffffffff" to "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when",
"0000000000000000000000000000000000000000000000000000000000000000" to "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art",
"7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f" to "legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title",
"8080808080808080808080808080808080808080808080808080808080808080" to "letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless",
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" to "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote",
"9e885d952ad362caeb4efe34a8e91bd2" to "ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic",
"6610b25967cdcca9d59875f5cb50b0ea75433311869e930b" to "gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog",
"68a79eaca2324873eacc50cb9c6eca8cc68ea5d936f98787c60c7ebc74e6ce7c" to "hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length",
"c0ba5a8e914111210f2bd131f3d5e08d" to "scheme spot photo card baby mountain device kick cradle pact join borrow",
"6d9be1ee6ebd27a258115aad99b7317b9c8d28b6d76431c3" to "horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave",
"9f6a2878b2520799a44ef18bc7df394e7061a224d2c33cd015b157d746869863" to "panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside",
"23db8160a31d3e0dca3688ed941adbf3" to "cat swing flag economy stadium alone churn speed unique patch report train",
"8197a4a47f0425faeaa69deebc05ca29c0a5b5cc76ceacc0" to "light rule cinnamon wrap drastic word pride squirrel upgrade then income fatal apart sustain crack supply proud access",
"066dca1a2bb7e8a1db2832148ce9933eea0f3ac9548d793112d9a95c9407efad" to "all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform",
"f30f8c1da665478f49b001d94c5fc452" to "vessel ladder alter error federal sibling chat ability sun glass valve picture",
"c10ec20dc3cd9f652c7fac2f1230f7a3c828389a14392f05" to "scissors invite lock maple supreme raw rapid void congress muscle digital elegant little brisk hair mango congress clump",
"f585c11aec520db57dd353c69554b21a89b20fb0650966fa0a9d6f74fd989d8f" to "void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold"
)
@Test
fun entropyGivesTheVectorMnemonic() {
vectors.forEach { (entropy, words) ->
assertEquals(words, MnemonicCreator.fromEntropy(entropy.fromHex()).words)
}
}
@Test
fun vectorMnemonicGivesBackItsEntropy() {
vectors.forEach { (entropy, words) ->
assertEquals(entropy, MnemonicCreator.fromWords(words).entropy.toHexString())
}
}
@Test
fun randomMnemonicHasTheRequestedLengthAndRoundTrips() {
Mnemonic.Length.values().forEach { length ->
val mnemonic = MnemonicCreator.randomMnemonic(length)
// Each word carries 11 bits; a checksum bit is added per 32 bits of entropy.
assertEquals(length.byteLength * 8 * 33 / 32 / 11, mnemonic.wordList.size)
assertTrue(mnemonic.entropy.contentEquals(MnemonicCreator.fromWords(mnemonic.words).entropy))
}
}
}