Category: Uncategorized

  • bash alias

    Option 3: Most comfortable (long-term) – SSH key + small alias on server

    1. Set up SSH key authentication (so no password typing for SSH)On Windows (PowerShell):PowerShellssh-keygen -t ed25519 -C "your@email.com" # press enter for defaultsThen copy the public key to server:PowerShelltype $HOME\.ssh\id_ed25519.pub | ssh FLOXII@xx.xx.xxx.xx "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"→ from now on ssh FLOXII@xx.xx.xxx.xx works without password
    2. Create aliases on the server (you only do this once)SSH to server:Bashssh FLOXII@xx.xx.xxx.xxThen edit ~/.bashrc:Bashnano ~/.bashrcAdd at the end:Bashalias dev='sudo docker exec -it data_tool_dev-nextjs_test-1 sh' alias dev-restart='sudo docker exec -it data_tool_dev-nextjs_test-1 sh -c "kill -SIGTERM 1 2>/dev/null || true && npm install && echo \"Starting Next.js...\" && npm start"' alias dev-logs='sudo docker logs -f data_tool_dev-nextjs_test-1'Save and reload:Bashsource ~/.bashrc
    3. Now from Windows you can run:PowerShellssh FLOXII@xx.xx.xxx.xx dev→ directly inside container (no sudo password needed if you configure sudoers — but even without it’s only one password)Or restart + install in one go:PowerShellssh FLOXII@xx.xx.xxx.xx dev-restart

  • How to Publish a NuGet Package for Your Next.js Project NPM

    Publishing a NuGet package for your Next.js project lets you share reusable React components or utilities with the world (or your team). Here’s a quick guide on what a NuGet package is, why you’d want to create one, and how to publish and consume it.

    What is a NuGet Package?

    A NuGet package is a shareable bundle of code hosted on npmjs.com. For a Next.js project, this typically includes React UI components or utility functions, as Next.js-specific features like API routes or file-system routing can’t be packaged due to their server-side nature.

    Why Create a NuGet Package?

    • Reusability: Share components or helpers across multiple projects.
    • Collaboration: Allow others to use your code via a simple npm install.
    • Versioning: Manage updates and dependencies with semantic versioning.

    How to Create and Publish a NuGet Package

    1. Set Up Your Project

    Create a Next.js project (or use an existing one) and focus on components or utilities. For example, a library of reusable React components.

    npx create-next-app@latest my-lib
    cd my-lib

    2. Configure package.json

    Ensure your package.json has the correct metadata. The package name must include your npm scope (e.g., @yourname/mylib). Example:

    {
      "name": "@flowiso/mylib",
      "version": "1.0.0",
      "main": "dist/index.js",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/flowxcode/mylib.git"
      },
      "scripts": {
        "build": "tsc"
      }
    }

    Note: The package name (e.g., @yourname/mylib) doesn’t need to match your GitHub repo name. The repository field links to your GitHub repo for metadata.

    3. Build Your Library

    Use TypeScript or a bundler like Rollup to compile your code into a dist folder. For a simple setup, add a tsconfig.json and run:

    npm install typescript --save-dev
    npx tsc --init
    npm run build

    4. Log In to npm

    Ensure you’re logged into npm with the correct account matching your scope:

    npm login
    npm whoami

    Verify it returns yourname (e.g., flowiso).

    5. Publish to npm

    For scoped packages (e.g., @yourname/mylib), you must specify public access:

    npm publish --access public

    Your package is now live at npmjs.com/@yourname/mylib! 🎉

    Pro Tip: Test locally before publishing to avoid version bumps:

    npm pack
    npm install ./yourname-mylib-1.0.0.tgz

    ⚠️ Next.js Limitation

    You can’t package Next.js API routes or file-system routing. Stick to React components or utilities.

    How to Consume Your Package

    In another project, install your package:

    npm install @yourname/mylib

    Import and use it in your code:

    import { MyComponent } from '@yourname/mylib';

    my pkg

    https://www.npmjs.com/settings/flowiso/packages

    https://github.com/flowxcode/njs-core

  • git screwing with my CR LF

    Your tools aren’t “screwing” with your file on a whim—they’re all following their configured rules for handling line endings. The core issue is that your Git settings and your editors’ settings are misaligned. Here’s the blunt truth:

    1. Git’s Role (core.autocrlf & .gitattributes):
      • Git stores files in the repo with LF by default. On Windows, if you’ve set core.autocrlf to true, Git should convert LF to CRLF on checkout and the reverse on commit.
      • If your core.autocrlf is set to false or input, Git won’t do any conversion on checkout, so you might end up with LF files on disk even on Windows.
      • A missing or misconfigured .gitattributes file can also lead to inconsistent behavior across different systems. Without it, Git might not enforce a consistent line ending policy.
    2. Editor Behavior:
      • VS Code: It can automatically set the end-of-line sequence based on its files.eol setting. If that’s set to \n (LF), then when you save the file, VS Code will force LF—even if the file originally came in as CRLF.
      • Notepad++: It shows what’s on disk. If it’s reading CRLF, that suggests one tool somewhere is converting your LF to CRLF on disk (or vice versa). Sometimes Notepad++ might be reporting what it “expects” based on its default Windows behavior.
      • GitKraken & Visual Studio: They generally rely on Git’s configuration. So if Git is normalizing to LF internally, these tools might show LF even though the file on disk might be CRLF when inspected in another editor.
    3. What’s Happening in Your Case:
      • You see the file as CRLF in Notepad++ but as LF in your local Git checkout (and when viewed in VS Code). That’s because somewhere in your workflow Git is normalizing the file to LF (likely because the repo has LF and your Git config isn’t set to convert back to CRLF on checkout).
      • When you save the file in VS Code, it’s saved with LF (because of its settings), so Git sees a complete line-ending change compared to the version stored with CRLF on origin or on other computers. This discrepancy makes Git mark the entire file as changed.
    4. How to Fix It:
      • Align Git Settings: Check your Git config with git config --get core.autocrlf. On Windows, if you want CRLF in your working directory, set it to true. If you prefer LF everywhere, set it to input (but then you might see these differences on other Windows machines expecting CRLF).
      • Use a .gitattributes File: Create a .gitattributes file in your repo root and add rules like:pgsqlCopy*.json text eol=crlf orarduinoCopy* text=auto This forces Git to treat files the same way on all systems.
      • Synchronize Editor Settings: Ensure VS Code’s files.eol (and similar settings in other editors) matches what you want. For CRLF on Windows, set it to \r\n.

    Bottom Line:
    It’s not GitKraken acting on its own; it’s your configuration mismatches. Git is doing exactly what it’s been told—storing files with LF in the repo and converting on checkout based on your settings. Your editors then might override or display differently based on their own configurations. Get your Git settings and your editors in sync (using a proper .gitattributes file is often the best solution), and the headache will be over.

    Fuck line endings—sort out your configs, and you’ll be golden.

    thx

    phase2:

    Alright, listen up. If you want every damn file—every single text file—in your working copy to be CRLF, you need to force Git to treat all files as text and then tell it to check them out with CRLF line endings. But let me be clear: Git is designed to store text files normalized (LF) in the repo and only convert on checkout. There’s no magic switch to store them as CRLF inside the Git objects, but your working directory can have CRLF everywhere.

    Here’s how to force it:

    1. Create or Edit Your .gitattributes File:
      In the root of your repo, create (or modify) a file called .gitattributes with this single line:arduinoCopy* text=auto eol=crlf This line tells Git to treat every file it can as text and, on checkout, convert line endings to CRLF.Warning: This only applies to files Git considers text. For files that Git heuristically thinks are binary, conversion won’t happen. Forcing binary files to convert is a disaster waiting to happen.
    2. Force Git to Reapply Conversion:
      If your files were already checked out before setting up your .gitattributes, Git isn’t going to magically convert them on its own. You need to force a re-checkout:bashCopygit rm --cached -r . git reset --hard This removes everything from the index and then checks them out again—now obeying your .gitattributes rules (and your core.autocrlf=true setting).
    3. Double-Check Your Editor Settings:
      • VS Code: Ensure your settings are not undoing your hard work. In your settings.json, set:jsonCopy"files.eol": "\r\n"
      • Notepad++/VS: Verify they’re not overriding the file’s CRLF status on save.
    4. Understand the Limitations:
      • Internal Repo Storage: Git will always store text files in normalized LF in its internal storage. You’ll see CRLF only in your working directory.
      • Binary Files: If there are files that are not meant to be text (like images or compiled binaries), leave them alone. Forcing a conversion on them could corrupt them.

    Bottom line:
    Create a .gitattributes file with * text=auto eol=crlf, force a full re-checkout, and make sure your editors are set to use CRLF. That’s the blunt truth—get your configs in sync and you’ll see CRLF everywhere you want.

  • difference between Infineon SLE 36 and SLE 78

    The Infineon SLE 36 and SLE 78 series are both families of security microcontrollers designed for secure applications such as smart cards, secure identification, and access control systems. However, they differ in several key aspects:

    Security Features

    • SLE 78: This series is known for its advanced security features like Integrity Guard, which provides full encryption of data paths and offers various countermeasures against physical and logical attacks.
    • SLE 36: Generally has basic security features and may not offer the advanced countermeasures against attacks that the SLE 78 series provides.

    Cryptographic Support

    • SLE 78: Supports a wide range of cryptographic algorithms including RSA, ECC, DES, and AES.
    • SLE 36: Typically supports basic cryptographic algorithms like DES and 3DES but lacks the extensive cryptographic capabilities of the SLE 78 series.

    Security Certification

    • SLE 78: Often certified to higher Common Criteria levels, such as CC EAL 6+, making it suitable for high-security applications.
    • SLE 36: May have some level of security certification but usually not as high as the SLE 78 series.

    Processing Speed and Memory

    • SLE 78: Generally offers higher processing speeds and more memory, suitable for applications that require fast data processing and more storage.
    • SLE 36: Typically has less memory and may operate at lower speeds.

    Use Cases

    • SLE 78: Because of its advanced features, it’s used in high-security applications like electronic passports, secure elements in mobile devices, and secure identification cards.
    • SLE 36: More suited for lower-security applications where cost-effectiveness is a priority but some level of security is still required.

    Given your background in security research, understanding these differences could be vital, especially if you’re evaluating the security of systems that utilize these microcontrollers. You may find it interesting to examine the trade-offs between security features and performance or cost in these two series.

  • NUnit from scratch

    https://github.com/nunit/nunit-vs-templates

    same here as below, dont want to install all sorts of things extensions etc to scour through exs

    https://github.com/nunit/dotnet-new-nunit
    skip this, trust me, it is trash 😉 and not compatible to open.

    https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit

    folllow up and self contained repo

    https://github.com/flowxcode/nunit-template

    according MS docs to test test the tests

    https://nunit.org/nunitv2/docs/2.6.4/quickStart.html

    started to debug, decided to analyse templates and MS description. building scratch project to debug and build up proper architecture

    /unit-testing-using-nunit
        unit-testing-using-nunit.sln
        /PrimeService
            Source Files
            PrimeService.csproj
        /PrimeService.Tests
            Test Source Files
            PrimeService.Tests.csproj

    https://docs.educationsmediagroup.com/unit-testing-csharp/nunit/lifecycle-of-a-test-fixture

    Lifecycle of a test fixture

    As mentioned before, NUnit gives the developer the possibility to extract all initialization and tear-down code that multiple tests might be sharing into ad-hoc methods.

    Developers can take advantage of the following facilities to streamline their fixtures

    • A method decorated with a SetUp attribute will be executed before each test
    • A method decorated with a TearDown attribute will be executed after each test
    • A method decorated with a OneTimeSetUp attribute will be executed before any test is executed
    • A method decorated with a OneTimeTearDown attribute will be executed after all tests have been executed
    • The class constructor will be executed before any method and can be used to prepare fields that shouldn’t be modified while executing the tests.

    Additionally, developers can set up fixtures contained in a namespace and all its children by creating a class decorated with the attribute SetUpFixture. This class will be able to contain methods decorated with OneTimeSetUp and OneTimeTearDown attributes.

    NUnit supports multiple SetUpFixture classes: in this case, setup methods will be executed starting from the most external namespace in and the teardown from the most internal namespace out.

    nunit

    References:

    https://automationintesting.com/csharp/nunit/lessons/whataretestfixtures.html

  • secure authentication

    read the counter of auth attempts:

    https://globalplatform.org/specs-library/card-specification-v2-3-1/

    The INITIALIZE UPDATE command is used, during explicit initiation of a Secure Channel, to transmit card and session data between the card and the host. This command initiates the initiation of a Secure Channel Session.

    read the counter of apdu.

    findings: counter ist increasing in 2 apdu responses

    https://www.rapidtables.com/convert/number/hex-to-decimal.html

    https://www.scadacore.com/tools/programming-calculators/online-hex-converter/

  • github pages automation projects

    gonna go with 3 gh pages repos, active at the moment. want to automate CV build and manage complex playgrounds and code books

    https://flowxcode.github.io/hpage/

    https://flowxcode.github.io/ghpages/

    https://flowxcode.github.io/devgimmickry/

  • snipped first #Groovy script for Jenkins

    whole Jenkins day today. started with log production and automation, ended in API triggers and log analytics.

    groovy script base for Jenkins . ! should be checked into SCCM to to jenkins per code proccess. So dont skip the funny parts and stay stuck halfway through.

    checked in some stubs, full project not disclosed

    https://github.com/flowxcode/shellexperimental

  • NUnit setup tmr for test setup

    things tbd tmr , details tobe provided and worked out

    • SetUpAttribute is now used exclusively for per-test setup.
    • TearDownAttribute is now used exclusively for per-test teardown.
    • OneTimeSetUpAttribute is used for one-time setup per test-run. If you run n tests, this event will only occur once.
    • OneTimeTearDownAttribute is used for one-time teardown per test-run. If you run n tests, this event will only occur once
    • SetUpFixtureAttribute continues to be used as at before, but with changed method attributes.
  • FactoryPattern adaptions real world

    adapt a pattern and build a reald world ex into it

    https://github.com/flowxcode/dotnet-design-patterns-samples#factory-method

    https://github.com/flowxcode/dotnet-design-patterns-samples/tree/master/Generating/FactoryMethod

    1. build pattern
    2. introduce config
    3. locate point from where to read config in current project
    4. read config early and compare in diagrams

    the factory pattern:

    https://dotnetcoretutorials.com/2019/10/15/the-factory-pattern-in-net-core/

    TestFixtureContextBase.cs
    DeviceMapper -> gets a new DeviceFactory creates Devices , Devices inherit from Device class.

  • TestFixture NUnit Tests floowww flow

    call stack directly after Test Class constructor:

    TestFixture.Core.TestFixtureContextBase.OneTimeSetup() Line 46 C#

  • .dll Type Library Importer Tlbimp.exe and Tlbexp.exe

    wanted to add AwUsbApi.dll lib but got

    trying to validate dlls

    https://stackoverflow.com/questions/3456758/a-reference-to-the-dll-could-not-be-added

    using VS Developer Command Prompt

    https://docs.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022

    C:\Program Files\Digi\AnywhereUSB\Advanced>tlbimp AwUsbApi.dll
    Microsoft (R) .NET Framework Type Library to Assembly Converter 4.8.3928.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    TlbImp : error TI1002 : The input file 'C:\Program Files\Digi\AnywhereUSB\Advanced\AwUsbApi.dll' is not a valid type library.
    
    C:\Program Files\Digi\AnywhereUSB\Advanced>Tlbexp AwUsbApi.dll
    Microsoft (R) .NET Framework Assembly to Type Library Converter 4.8.3928.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    TlbExp : error TX0000 : Could not load file or assembly 'file:///C:\Program Files\Digi\AnywhereUSB\Advanced\AwUsbApi.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

    ist not the first problem. already encountered on digi forum

    https://www.digi.com/support/forum/27954/problems-with-awusbapi-dll

  • contd REST API set up

    extended path on post:

    additional base preps:

    IIS:

    Firewall:

    related:

  • string empty or “”

    one pretty fundamental answer:

    c stackoverflow:

    There really is no difference from a performance and code generated standpoint. In performance testing, they went back and forth between which one was faster vs the other, and only by milliseconds.

    In looking at the behind the scenes code, you really don’t see any difference either. The only difference is in the IL, which string.Empty use the opcode ldsfld and "" uses the opcode ldstr, but that is only because string.Empty is static, and both instructions do the same thing. If you look at the assembly that is produced, it is exactly the same.

    C# Code

    private void Test1()
    {
        string test1 = string.Empty;    
        string test11 = test1;
    }
    
    private void Test2()
    {
        string test2 = "";    
        string test22 = test2;
    }
    

    IL Code

    .method private hidebysig instance void 
              Test1() cil managed
    {
      // Code size       10 (0xa)
      .maxstack  1
      .locals init ([0] string test1,
                    [1] string test11)
      IL_0000:  nop
      IL_0001:  ldsfld     string [mscorlib]System.String::Empty
      IL_0006:  stloc.0
      IL_0007:  ldloc.0
      IL_0008:  stloc.1
      IL_0009:  ret
    } // end of method Form1::Test1
    
    .method private hidebysig instance void 
            Test2() cil managed
    {
      // Code size       10 (0xa)
      .maxstack  1
      .locals init ([0] string test2,
                    [1] string test22)
      IL_0000:  nop
      IL_0001:  ldstr      ""
      IL_0006:  stloc.0
      IL_0007:  ldloc.0
      IL_0008:  stloc.1
      IL_0009:  ret
    } // end of method Form1::Test2
    

    Assembly code

            string test1 = string.Empty;
    0000003a  mov         eax,dword ptr ds:[022A102Ch] 
    0000003f  mov         dword ptr [ebp-40h],eax 
    
            string test11 = test1;
    00000042  mov         eax,dword ptr [ebp-40h] 
    00000045  mov         dword ptr [ebp-44h],eax 
    
            string test2 = "";
    0000003a  mov         eax,dword ptr ds:[022A202Ch] 
    00000040  mov         dword ptr [ebp-40h],eax 
    
            string test22 = test2;
    00000043  mov         eax,dword ptr [ebp-40h] 
    00000046  mov         dword ptr [ebp-44h],eax 

    https://stackoverflow.com/a/1588678/1650038

  • COMException

    System.Runtime.InteropServices.COMException (0x800703FA): Retrieving the COM class factory for component with CLSID {82EAAE85-00A5-4FE1-8BA7-8DBBACCC6BEA} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (0x800703FA).
    at System.RuntimeTypeHandle.AllocateComObject(Void* pClassFactory)
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
    at System.Activator.CreateInstance(Type type)
    at …

    Solution

    moved instance into ctor

    public KeoObj()
    {
      _proxiLab = (IProxiLAB)Activator.CreateInstance(Type.GetTypeFromProgID("KEOLABS.ProxiLAB"));
    }

    always a charm, clean code:

    possible relevance:

    https://stackoverflow.com/questions/21941216/using-application-pool-identity-results-in-exceptions-and-event-logs

    link base:

    http://adopenstatic.com/cs/blogs/ken/archive/2008/01/29/15759.aspx

  • the AMR command

    section 4.5.1, APPLICATION MANAGEMENT REQUEST (AMR) Command

    https://globalplatform.org/wp-content/uploads/2014/03/GPC_ISO_Framework_v1.0.pdf

    ideas tear and check and repeat.

    run multiple parameterized tests with NUnit as in:

    https://www.lambdatest.com/blog/nunit-parameterized-test-examples/

            [Test]
            [TestCase("chrome", "72.0", "Windows 10")]
            [TestCase("internet explorer", "11.0", "Windows 10")]
            [TestCase("Safari", "11.0", "macOS High Sierra")]
            [TestCase("MicrosoftEdge", "18.0", "Windows 10")]
            [Parallelizable(ParallelScope.All)]
            public void DuckDuckGo_TestCase_Demo(String browser, String version, String os)
            {
                String username = "user-name";
                String accesskey = "access-key";
                String gridURL = "@hub.lambdatest.com/wd/hub";

  • share IIS site o API on local intranet win10 11

    https://docs.microsoft.com/en-us/iis/get-started/getting-started-with-iis/create-a-web-site

    https://superuser.com/a/263893/237029

    open firewall ports for spec site cause only port 80 default website is open std.

    https://manage.accuwebhosting.com/knowledgebase/2886/How-to-Configure-IIS-to-Access-Your-Website-using-an-IP-Address.html

    always start first with an easy landing page and add api or biz domain functions later on. step by step, eliminate possible error sources..

  • Logging in ASP.NET Web API Pitfalls

    First of all: Use a LogViewer eg LogViewPlus or lightweight LogViewer of uvviewsoft com. Makes your life a lot easier.

    Pitfall1: logfiles getting too big.

  • semi dependant API calls sequence in REST realm

    https://www.quora.com/What-does-state-mean-in-Representational-State-Transfer-REST

    The fundamental explanation is:

    No client session state on the server.

    but this time we introduce builder.Services.AddSingleton<XObj>();

    from my observation, I put activated the Init function after tearing cause the PICC time out occured afterwards. Tcl: //ERROR (code 5): PICC response timed out.

    Tcl transmissions worked again after init protocols

    err = TransmitTearing(txBuffer, out rxBuffer);
    initResult = SendActivationHttpRequest().GetAwaiter().GetResult();
  • tearing smartcard RF power

    tearing power from cards during command execution. Keolabs SPulse option triggered by Command PCD_EOF triggers RF_POWER output, cycles parameter to align tearing moment.

    keo.Spulse.LoadSpulseCsvFile(filepath, fdt, (uint)eFrameTypeFormat.FRAME_TYPE_SPULSE, (uint)eEmulatorLoadSpulseMode.STAND_ALONE);
    keo.Spulse.EnableSpulse((uint)eEmulatorSpulseEvent.SP_PCD_EOF, (uint)eEmulatorSpulseOutput.SP_RF_POWER);
    keo.Reader.ISO14443.SendTclCommand(0x00, 0x00, ref txBuffer[0], (uint)txBuffer.Length, out rxBuffer[0], (uint)rxBuffer.Length, out rxBufferLength);
  • cryptography

    moving keysets.. AES DES

    "Keyset_48_AES": "",
    "Keyset_00_DES": "",
    "Keyset_FF_DES": "",
    AES (Rijndael) Round Function.png
    AES round function (c wiki)
  • vs code and ProxiLAB

    trying SCRIPTIS but debugger is flaky so VS Code got the shot once again.

        error = ProxiLAB.Reader.ISO14443.SendTclCommand(0x00, 0x00, TxBuffer, RxBuffer)
        if (error[0]):
            print("Tcl: {0}".format(ProxiLAB.GetErrorInfo(error[0])))
            PopMsg += "Tcl: {0}".format(ProxiLAB.GetErrorInfo(error[0])) + "\n"
        else:
            print("Tcl response: " + ''.join(["0x%02X " % x for x in RxBuffer.value]))
            PopMsg +=  "Tcl response: " + ''.join(["0x%02X " % x for x in RxBuffer.value]) + "\n"

    Tcl response: 0x6A 0x86

  • keolabs ProxiLAB Quest

    doing some #python tests GetCard SendCommand for ISO/IEC 14443 smartcards.

    • python run and trace in Quest software as well as RGPA software. disadvantage missing debugging comf
    • so moved to VS Code with python and Keolabs lib python file
    • searching for implementation file and possible dlls for c# integration
    • Poller0 PCD proximity coupling device and PICC
    • challenge is to set up full python setup outside of delivered Quest. API functions full details?

    https://diglib.tugraz.at/download.php?id=5f588b91684cf&location=browse

    https://github.com/scriptotek/pyrfidgeek/blob/61595be017fe56f1f668422c15bc50354274a310/rfidgeek/rfidgeek.py#L122

        def inventory_iso14443A(self):
            """
            By sending a 0xA0 command to the EVM module, the module will carry out
            the whole ISO14443 anti-collision procedure and return the tags found.
                >>> Req type A (0x26)
                <<< ATQA (0x04 0x00)
                >>> Select all (0x93, 0x20)
                <<< UID + BCC
            """
            response = self.issue_evm_command(cmd='A0')
    
            for itm in response:
                iba = bytearray.fromhex(itm)
                # Assume 4-byte UID + 1 byte Block Check Character (BCC)
                if len(iba) != 5:
                    logger.warn('Encountered tag with UID of unknown length')
                    continue
                if iba[0] ^ iba[1] ^ iba[2] ^ iba[3] ^ iba[4] != 0:
                    logger.warn('BCC check failed for tag')
                    continue
                uid = itm[:8]  # hex string, so each byte is two chars
    
                logger.debug('Found tag: %s (%s) ', uid, itm[8:])
                yield uid
    
                # See https://github.com/nfc-tools/libnfc/blob/master/examples/nfc-anticol.c
  • cache hacks

    https://dmalcolm.fedorapeople.org/gcc/2015-08-31/rst-experiment/how-to-use-inline-assembly-language-in-c-code.html#clobbers

    compiler explorer:
    https://godbolt.org/z/kANkNL

    void maccess(void *p) { asm volatile("movq (%0), %%rax\n" : : "c"(p) : "rax"); }

    moves quadword from mem adress into rax register
    AT&T syntax?

    shm_open and mmap:

    quote: mmap works in multiples of the page size on your system. If you’re doing this on i386/amd64 or actually most modern CPUs, this will be 4096.

    In the man page of mmap on my system it says: “offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).”. On some systems for historical reasons the length argument may be not a multiple of page size, but mmap will round up to a full page in that case anyway.

  • compiler life

    src/test/resources/public/input/lexer/fail01.jova

  • gradle and antlr for compiler set ups

    Commands:
    ./gradlew compileJava
    ./gradlew compileTestJava
    ./gradlew printTree -PfileName=PATH_TO_JOVA_FILE
    ./gradlew clean

    ./gradlew compileJava && ./gradlew compileTestJava && ./gradlew printTree -PfileName=PATH_TO_JOVA_FILE && ./gradlew clean
    ./gradlew printTree -PfileName=main/antlr/at/tugraz/ist/cc/Calc.g4

    gradlew permission denied
    https://www.cloudhadoop.com/gradlew-permission-denied/

    src/test/resources/public/input/lexer

  • homomorphic encryption

    https://www.techtarget.com/searchsecurity/definition/homomorphic-encryption

    quote: “

    Homomorphic encryption is the conversion of data into ciphertext that can be analyzed and worked with as if it were still in its original form.  

    Homomorphic encryptions allow complex mathematical operations to be performed on encrypted data without compromising the encryption. In mathematics, homomorphic describes the transformation of one data set into another while preserving relationships between elements in both sets.  The term is derived from the Greek words for “same structure.” Because the data in a homomorphic encryption scheme retains the same structure, identical mathematical operations — whether they are performed on encrypted or decrypted data —  will yield equivalent results.

    Homomorphic encryption is expected to play an important part in cloud computing, allowing companies to store encrypted data in a public cloud and take advantage of the cloud provider’s analytic services.

    Here is a very simple example of how a homomorphic encryption scheme might work in cloud computing:

    • Business XYZ has a very important data set (VIDS) that consists of the numbers 5 and 10.  To encrypt the data set, Business XYZ multiplies each element in the set by 2, creating a new set whose members are 10 and 20.
    • Business XYZ sends the encrypted VIDS set to the cloud for safe storage.  A few months later, the government contacts Business XYZ and requests the sum of VIDS elements.   
    • Business XYZ is very busy, so it asks the cloud provider to perform the operation.  The cloud provider, who only has access to the encrypted data set,  finds the sum of 10 + 20 and returns the answer 30.
    • Business XYZ decrypts the cloud provider’s reply and provides the government with the decrypted answer, 15.

    there is a python lib PySEAL

    https://gab41.lab41.org/pyseal-homomorphic-encryption-in-a-user-friendly-python-package-e27547a0b62f

    https://blog.openmined.org/build-an-homomorphic-encryption-scheme-from-scratch-with-python/

    https://bit-ml.github.io/blog/post/homomorphic-encryption-toy-implementation-in-python/

  • Private Information Retrieval

    Additive Secret Sharing

    Since all shares (except for one) are chosen randomly, every share is indistinguishable from a random
    value and no one can learn anything about a by observing at most n − 1 shares.

    Shamir Secret Sharing

    Drawback of additive secret sharing is that parties can drop out and fail to provide their share.

    For both sharing methods, holders of the secret shares can compute linear functions on their shares.

    PrivaGram

    encode index of the chosen image in a bit string using one-hot encoding
    XOR

    adding robustness

    Shamir secret sharing instead of additive secret sharing

    • robust against server dropping out, k-out-of-l PIR
    • at least t+1 servers are required to reconstruct the secret., t-private-l-server PIR

    t-private k-out-of-l PIR protocol

    adding homomorphic encryption

    collude

    final protocol

    tbd

  • Secure Classification

    Secure Multiparty Computation like Yao’s Millionaires’ Problem [Yao82]

    SPDZ
    http://bristolcrypto.blogspot.com/2016/10/what-is-spdz-part-1-mpc-circuit.html

    A secret value x is shared amongst n parties, such that the sum of all shares are equal to x.

    • uniformly at random

    adding sec

    • in SPDZ MACs are used to authenticate the shares.
    • global MAC key
    • each party knows a share of the global MAC key

    sharing an input value

    • sharing masked version of x
    • each party computes <x>

    next:

    opening a value
    partially
    output
    directional output
    MAC check protocol
    coin tossing protocol
    commitments

  • c++ in docker and VS Code

    https://code.visualstudio.com/docs/remote/containers

    https://code.visualstudio.com/docs/remote/containers-tutorial

    g++ main.cpp -o main.out

    mkdir build && cd build && cmake .. && make test
    cd build && cmake .. && make test
    cmake .. && make test

    docker container ls –all
    docker exec -it quizzical_banach /bin/bash

    docker ps -a
    docker start NAME

    docker container ls // running

    // visual studio notifies if to reopen the workspace in container…

    apt list –installed

  • Boston Housing Data Analysis

    API
    https://www.tensorflow.org/api_docs/python/tf/keras/datasets/boston_housing/load_data

    Samples contain 13 attributes of houses at different locations around the Boston suburbs in the late 1970s. Targets are the median values of the houses at a location (in k$).

    http://lib.stat.cmu.edu/datasets/boston

    404×13 = 5252

    y_train x_train 404 samples
    y_test x_test 102 samples
    x 13
    y 1 target scalar

    y_train, y_test: numpy arrays of shape (num_samples,) containing the target scalars. The targets are float scalars typically between 10 and 50 that represent the home prices in k$.